isar / isar/hive

Flutter: Hive database is working well but when restarting the app the data is disappeared

Open
#836 5 comments 1 reaction 0 assignees View on GitHub
problem
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

This is Hive setup in main function that I open a box and also put the registerAdapter as I said in the question that everything is okay but when restarting the app data lost

```
void main() async {
WidgetsFlutterBinding.ensureInitialized();

await Hive.initFlutter();

Hive.registerAdapter(QuestionModelAdapter());
await Hive.openBox("saveQuestion");

runApp(const MyApp());
}
```

This is the class I used in hive class.
```
import 'package:hive/hive.dart';

part 'question.g.dart';

@HiveType(typeId: 0)
class QuestionModel {
@HiveField(0)
String title;

@HiveField(1)
List options;

QuestionModel({
required this.title,
required this.options,
});
}

```
**Version**
- Platform: Android
- Flutter version: [2.0.0]
- Hive version: [2.0.4]

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.