writeToPersistentStorage method Null safety

Future<void> writeToPersistentStorage()

Implementation

Future<void> writeToPersistentStorage() async {
  if (!_needsSave) {
    return;
  }
  _needsSave = false;
  final storage = await SharedPreferences.getInstance();
  String js = json.encode(toJson());
  await storage.setString('init', js);
}