isar / isar/hive

Storing dart class and List<String> in it, List<String> not getting persisted

Open
#1,052 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

I have a class like following

**Code sample**
```dart
@HiveType(typeId: HiveConstants.APP_SETTING_INDEX)
class AppSettings {
AppSettings({
required this.localeString,
required this.searchHistory,
});

@HiveField(0)
String localeString;

@HiveField(1, defaultValue: ['default'])
List searchHistory;

}
```

Now data persists as soon as app is opened, but as soon as app is closed List becomes empty []. This hive box already existed I just add one more field `searchHistory` with code as 1. localeString is persisted.

Do I need to use `.flush()` always, I have not been using `.flush()` and its working fine in all other places.

**Version**
- Platform: Android
- Flutter version: 3.0.0
- hive
hive: ^2.2.2
hive_flutter: ^1.1.0

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.