Question
In HiveList. i can get a.b get b list
but when i use a.b.b1 want get b1 list, i get []
@rizzi37 could you please paste your code here?
closed~ i found func clear is Future.
closed~ i found func clear is Future.
i like to know how you make this strategy on hive
here is example~
void main() async {
Hive.registerAdapter(PersonAdapter());
var persons = await Hive.openBox<Person>('personsWithLists');
await persons.clear(); // here clear before data, if no await, your data is no useful until you refresh your app in flutter or lost
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 friends
/// create in hivelist
alex.friends = HiveList(persons); // Create a HiveList
alex.friends.addAll([luna]); // from mario get alex friend luna
print(mario.friends);
luna.delete(); // Remove Luna from Hive
print(mario.friends); // HiveList updates automatically
}
in my app only different is use multiple box relationship.. here is in one box.
Most helpful comment
here is example~
in my app only different is use multiple box relationship.. here is in one box.