'When / where is the best time / location to "open" HiveDB boxes in a Flutter app?
According to the HiveDB docs, when you "open" a box using Hive.openBox<E>('testBox');
all the data contained within the box is loaded into memory for immediate access.
Based on all the HiveDB + Flutter tutorials I've seen so far, most of them just open the boxes right away when the app starts so that the boxes can be accessed at anytime within the running lifespan of the app.
This brings up a concern that for a Flutter app utilizing several boxes possibly containing large amounts of data, waiting for all boxes to open / load into memory right on app launch could possibly take some time that the user might find annoying and also seems memory inefficient if everything is loaded into memory even if it isn't immediately needed.
Does anyone have any suggestions as to where in a Flutter app's lifecycle is the best place to open HiveDB boxes? Should they all be opened right at the beginning (possibly making the user wait for them to open) or is it better to open boxes right before they are needed (possibly making the user wait at a different spot when they are saving / accessing data)?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|