title: HiveError: The box "user" is already open and of type Box<User>
body: <p>I'm trying to use <code>Hive</code> inside flutter <code>Mobx</code>, after checking user data in <code>Hive</code> I switched to another screens such as <code>HomeView</code> or <code>Intro</code></p>
  <p><code>main.dart</code>:</p>
  <pre><code>Future&lt;void&gt; main() async {
    ...
  
    final appDocumentDirectory = await path_provider.getApplicationDocumentsDirectory();
    Hive.init(appDocumentDirectory.path);
    Hive.registerAdapter(UserAdapter());
  
    _setUpLogging();
  
    runApp(MultiProvider(providers: providers, child: StartupApplication()));
  }
  </code></pre>
  <p><code>StartupApplication</code> class: I don't use <code>Hive</code></p>
  <pre><code>class StartupApplication extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      final isPlatformDark = WidgetsBinding.instance.window.platformBrightness == Brightness.dark;
      final initTheme = isPlatformDark ? nebrassLightTheme : nebrassLightTheme;
      return ThemeProvider(
        initTheme: initTheme,
        duration: const Duration(milliseconds: 400),
        child: Builder(builder: (context) {
          return MaterialApp(
            title: 'TEST',
            theme: ThemeProvider.of(context),
            home: const OverlaySupport(child: OKToast(
             child: MyHomePage() //--&gt; checking user data widget
            )),
            onGenerateRoute: Routes.sailor.generator(),
            navigatorKey: Routes.sailor.navigatorKey,
          );
        }),
      );
    }
  }
  </code></pre>
  <p>checking <code>User</code> in <code>Hive</code> inside <code>MyHomePage</code> class:</p>
  <pre><code>class MyHomePage extends StatefulWidget {
    const MyHomePage({Key key}) : super(key: key);
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
      class _MyHomePageState extends State&lt;MyHomePage&gt; {
        @override
        Widget build(BuildContext context) {
          return FutureBuilder&lt;Box&lt;User&gt;&gt;(
              future: Hive.openBox('user'),
              builder: (context, snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  final Box&lt;User&gt; userBox = snapshot.data;
      
                  if (userBox.values.isNotEmpty &amp;&amp; userBox.get(0).active == 1) {
                    return HomeView();
                  } else {
                    return Intro();
                  }
                } else {
                  return Container();
                }
              });
        }
      
        @override
        void dispose() {
          Hive.close();
          super.dispose();
        }
      }
  </code></pre>
  <p>now in other screen such as <code>RegisterScreen</code> class I implemented <code>MobX</code> and inside that I want to use <code>user</code> box, for example:</p>
  <pre><code>class Register extends StatefulWidget {
    @override
    _RegisterState createState() =&gt; _RegisterState();
  }
  
  class _RegisterState extends State&lt;Register&gt; {
    TextEditingController _mobileNumber;
  
    final GlobalKey&lt;ScaffoldState&gt; _scaffoldState = GlobalKey&lt;ScaffoldState&gt;();
  
    @override
    void initState() {
      super.initState();
      _mobileNumber = TextEditingController();
    }
  
    @override
    Widget build(BuildContext context) {
      final _registerViewModel = Provider.of&lt;RegisterViewModel&gt;(context, listen: false);
  
      return Directionality(
        textDirection: TextDirection.ltr,
        child: Scaffold(
          key: _scaffoldState,
  
          ...
          //_registerViewModel.registerAccount(_mobileNumber.text, '111');
  
        ),
      );
    }
  
    void _showSnackBar(String message, BuildContext context) {
      _scaffoldState.currentState.showSnackBar(SnackBar(
          content: Directionality(
              textDirection: TextDirection.rtl,
              child: Text(
                '$message',
                style: AppTheme.of(context).caption().copyWith(color: Colors.white),
              ))));
    }
  }
  </code></pre>
  <p><code>MobX</code> implementation:</p>
  <pre><code>enum RegisterLoadingState { loading, done }
  enum ActiveLoadingState { loading, done }
  enum RegisteringState { initial, registered, activated, registerError, activeError }
  
  class RegisterViewModel = _RegisterViewModel with _$RegisterViewModel;
  
  abstract class _RegisterViewModel with Store {
    final WebApi _webApi;
  
    _RegisterViewModel({@required WebApi webApi}) : _webApi = webApi;
  
    ...
  
    @action
    Future&lt;void&gt; registerAccount(String mobileNumber, String deviceId) async {
      final RegisterRequest _request = RegisterRequest(mobileNumber, deviceId);
      try {
        loadingState = RegisterLoadingState.loading;
        final _res = await _webApi.register(_request);
        loadingState = RegisterLoadingState.done;
  
        _registerResponse = RegisterResponse.fromJson(_res.body as Map&lt;String, dynamic&gt;);
  
        /* I GET ERROR IN THIS LINE -- HiveError: The box &quot;user&quot; is already open and of type Box&lt;User&gt;.*/
  
        final userBox = await Hive.openBox('user');
        final user = User(/*...*/);
        userBox.putAt(0, user);
    }
  
    @action
    Future&lt;void&gt; activeAccount(String mobileNumber, String verifyCode) async {
      final ActiveAccountRequest _activeAccount = ActiveAccountRequest(mobileNumber, verifyCode);
  
      final userBox = await Hive.openBox('user');
      final User currentUser = userBox.getAt(0) as User;
      final user = User(/*...*/);
      userBox.putAt(0, user);
    }
  }
  </code></pre>