You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code sample
This is an extract from the Relationships section of hive docs.
voidmain() async {
Hive.registerAdapter(PersonAdapter());
var persons =awaitHive.openBox<Person>('personsWithLists');
persons.clear();
var mario =Person('Mario');
var luna =Person('Luna');
var alex =Person('Alex');
persons.addAll([mario, luna, alex]);
mario.friends =HiveList(persons); // Create a HiveList
mario.friends.addAll([luna, alex]); // Update Mario's friendsprint(mario.friends);
luna.delete(); // Remove Luna from Hiveprint(mario.friends); // HiveList updates automatically
}
The last line outputs [alex], meaning HiveList (mario.friends) holds a value in it.
I thought the value would be stored in the .hive file and the next code would still output [alex], but actually resulted in [].
voidmain() async {
Hive.registerAdapter(PersonAdapter());
var persons =awaitHive.openBox<Person>('personsWithLists');
var mario = persons.getAt(0);
mario.friends =HiveList(persons);
print(mario); // Marioprint(mario.friends); // []
}
Is it an expected behaviour?
Commenting out the line of mario.friends = HiveList(persons); in the second code did not affect the result.
Version
Platform: Windows
Flutter version: N/A (Dart only)
Hive version: 1.3.0
The text was updated successfully, but these errors were encountered:
Steps to Reproduce
See below.
Code sample
This is an extract from the Relationships section of hive docs.
The last line outputs
[alex]
, meaning HiveList (mario.friends
) holds a value in it.I thought the value would be stored in the .hive file and the next code would still output
[alex]
, but actually resulted in[]
.Is it an expected behaviour?
Commenting out the line of
mario.friends = HiveList(persons);
in the second code did not affect the result.Version
The text was updated successfully, but these errors were encountered: