incrementOrInitInt method

Future<int> incrementOrInitInt(
  1. String key, {
  2. int incrementBy = 1,
  3. int initialValue = 0,
})

Increments or initializes an integer value.

Implementation

Future<int> incrementOrInitInt(String key,
    {int incrementBy = 1, int initialValue = 0}) async {
  int currentValue = _prefs?.getInt(key) ?? initialValue;
  int newValue = currentValue + incrementBy;
  await saveInt(key, newValue);
  return newValue;
}