writeToPersistentStorage method Null safety
Implementation
Future<void> writeToPersistentStorage() async {
// We could query needsSave here, but this is called infrequently.
// A full audit to make sure needsSave is always updated would be needed
// to restore the query here.
needsSave = false;
final storage = await SharedPreferences.getInstance();
String js = json.encode(toJson());
await storage.setString(_persistentStorageKey, js);
}