Does not update , unless reinstalled
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
**Question**
this is my function to initialize Hive and put some dummy data inside it if its empty , the but the data doesnt gets displayed , what i figured out is that its not even getting called on the hot restarts or reloads not even when i close the app the rebuild it , the only time the when i can see the updated values of the dummyDietPlan is when i uninstall the app and build it again , why is the _initializeHive() is only getting called once in the life time of the app ?
other than this issue , everything else working fine with hive , but just cant figure out why this issue is coming up
**Code sample**
```dart
void initState() {
super.initState();
_initializeHive();
_checkDietIsViewed();
}
Future _initializeHive() async {
if (!isInitialized) {
await HiveService.initHive();
setState(() {
isInitialized = true;
});
}
}
Future _initializeDummyData() async {
final dietPlans = await HiveService.retrieveDietPlan();
if (dietPlans.isEmpty) {
final dummyDietPlan = DietPlan( ... // dummy diet plan inserted
await HiveService.UpdateDietPlan(dummyDietPlan);
await HiveService.printDietPlans();
}
}
Widget build(BuildContext context) {
return Scaffold(
body: FutureBuilder>(
future: HiveService.retrieveDietPlan(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
} else if (snapshot.hasError) {
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
// Call _initializeHiveAndData() here to handle empty data
_initializeHive();
return Text('No diet plans available.');
} else {
final dietPlans = snapshot.data!;
return ListView.builder(
}
},
),
);
}
}
```
**Version**
Platform: iOS, Android
- Flutter version: [e.g. 1.5.4]
hive: ^2.2.3
hive_flutter: ^1.1.0
build_runner: ^2.4.6
hive_generator: ^2.0.0
Attaching the before and after reinstallation ScreenShots


Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the initState, _initializeHive, _initializeDummyData, and FutureBuilder flow shown in the report, especially how HiveService initialization and data retrieval are ordered. There is no repository file or test named; done would mean identifying a reproducible initialization path in which updated dummy data appears without reinstalling the app.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- databases, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100