title: Flutter RepositoryProvider and hive LateInitializationError, How can I avoid this?
body: <p>Please someone help me! I have app where I am using Bloc and Hive.
  main.dart</p>
  <pre><code> void main() async {
    WidgetsFlutterBinding.ensureInitialized();
    final appDocumentDirectory =
        await path_provider.getApplicationDocumentsDirectory();
    await Hive.initFlutter(appDocumentDirectory.path);
  
    runApp(
      const MyApp(),
    );
  }
  </code></pre>
  <p>On MyApp widget registered MultiRepositoryProvider</p>
  <pre><code>return MultiRepositoryProvider(
    providers: [
      RepositoryProvider(create: (context) =&gt; AccountService()),
    ],
    child: MultiBlocProvider(
      providers: [
        BlocProvider&lt;AccountBloc&gt;(
          create: (context) =&gt; AccountBloc(context.read&lt;AccountService&gt;()),
        ),
      ],
      child: MaterialApp(
        home: const AppPage(),
      ),
    ),
  );
  </code></pre>
  <p>AppPage Contains bottomNavigationBar and some pages</p>
  <p>account.dart</p>
  <pre><code>class AccountService {
    late Box&lt;Account&gt; _accounts;
    AccountService() {
      init();
    }
  
    Future&lt;void&gt; init() async {
      Hive.registerAdapter(AccountAdapter());
      _accounts = await Hive.openBox&lt;Account&gt;('accounts');
  }
  </code></pre>
  <p>On appPage have BlocBuilder</p>
  <pre><code>BlocBuilder&lt;AccountBloc, AccountState&gt;(
  builder: (context, state) {
    if (state.accountStatus == AccountStatus.loading) {
      return const CircularProgressIndicator();
    } else if (state.accountStatus == AccountStatus.error) {
      Future.delayed(Duration.zero, () {
        errorDialog(context, state.error);
      });
    }
    return SingleChildScrollView(....
  </code></pre>
  <p>When app first loaded I receive LateInitializationError that late Box _accounts from account Repository not initialized. But as soon as I navigate to another page and go back, the Box _accounts are initialized and the data appears. How can I avoid this error and initialize the Hive box on application load?</p>