toggleTotalNotification method Null safety

void toggleTotalNotification(
  1. String prefsKey
)

Implementation

void toggleTotalNotification(String prefsKey) async {
  Map<String, dynamic>? data = getJson(prefsKey);
  if (data == null) {
    await init(force: true);
    data = getJson(prefsKey);
  }

  if (data!["on"] == true) {
    data["on"] = false;
  } else {
    data["on"] = true;
  }

  setJson(prefsKey, data);
  notifyListeners();
}