onPause static method

void onPause()

Implementation

static void onPause() async {
  final currentTime = DateTime.now();
  final usageDuration = currentTime.difference(_startTime);

  var oldDuration = await iCloudStorage.getString("usageMinutes") ?? "0";

  var newDuration = double.parse(oldDuration) +
      double.parse((usageDuration.inSeconds / 60).toStringAsFixed(2));

  iCloudStorage.writeString(
      key: "usageMinutes", value: newDuration.toString());
  PurchaseHelper.setAnalyticData("usageMinutes", newDuration);

  Helper.updateUser();
}