I save a List to an index in a Hive Box.
class Person {
String name;
Person(this.name);
}
List<Person> friends = [];
friends.add(Person('Jerry'));
var accountBox = Hive.openBox('account');
accountBox.put('friends',friends);
//Testing as soon as saved to make sure it's storing correctly.
List<Person> friends = accountBox.get('friends');
assert(friends.length == 1);
so all this works as intended.
For some crazy reason when I hot restart the app and try to get the list of friends from Hive, it no longer returns a List<Person>
. It returns a List<dynamic>
var accountBox = Hive.openBox('account');
List<Person> friends = accountBox.get('friends');
///ERROR
E/flutter (31497): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled
Exception: type 'List<dynamic>' is not a subtype of type 'List<Person>'
E/flutter (31497): <asynchronous suspension>
etc...
What could be causing this? It's so unusual.