Flutter hive data is shown after restarting the app on android

Viewed 328

I am using latest version of hive and hive_flutter. On background handler when notification is received i save the data in hive box. But it is not shown in the app when i restart the application then the box show the data.

I am using below code to read the data from the box.

ValueListenableBuilder(
          valueListenable: Boxes.getConnections().listenable(),
          builder: (BuildContext context, Box<Connections> box, _) {
            final connection = box.values.toList();
},)

In the main function i am using below code

 await Hive.initFlutter();
  if (Hive.isAdapterRegistered(0) == false) {
    Hive.registerAdapter(ConnectionsAdapter(), override: true);
  }

  if (Hive.isBoxOpen('connection_box') == false) {
    print('already close');
    await Hive.openBox<Connections>('connection_box');
  }
0 Answers
Related