Open vuaavan opened 3 years ago
i had this problem. i fix this problem like this
if (store.read('docs') is DocsModel) { return model = store.read('docs'); } else { return model = DocsModel.fromJson(store.read('docs')); }
@vuaavan I also had this problem, I just encode my list into a string and decode it later, respectively:
`
final localResults = GetStorage().read(StorageKeys.alertCheckResults);
if (localResults != null) {
final decodedData = json.decode(localResults as String);
combinedResults.addAll(
(decodedData as List<dynamic>).map((el) => AlertCheckResult.fromMap(el as Map<String, dynamic>)),
);
}
GetStorage().write(StorageKeys.alertCheckResults, json.encode(combinedResults.map((el) => el.toMap()).toList()));
`
I have 2 model : House and Room with 4 screen with tree map List house > Edit house > List room > Edit room / Add room . Problem happens with List room screen. In
List room controller
, I get list all room with :List rooms = GetStorage().read<List>('rooms');
In first time, while start app, I go to List room screen, result of rooms is List of Map, like : [{id: 1, name: Alpha Room, totalPeople: 1, floor: 1}, {id: 2, name: Beta Room, totalPeople: 2, floor: 1} ....]but, if I add a new room and save to storage
GetStorage().write('rooms', rooms.toList());
and go back screen Edit house and to screen List room again, i got list of instance of Room.What is diffirent in 2 situation ?
_flutter 2 get: ^3.26.0 getstorage: ^1.4.0