isFirstCall static method

Future<bool> isFirstCall()

Returns true if this is the first time this function has been called since installing the app, otherwise false.

In contrast to IsFirstRun.isFirstRun(), this method only returns true on the first call after installing the app, while IsFirstRun.isFirstRun() continues to return true as long as the app is running after calling it the first time after installing it.

Implementation

static Future<bool> isFirstCall() async {
  await _ensureInitialized();
  bool? firstCall = _db.get(_firstCallSettingsKey);
  if (firstCall == null) {
    // check in shared preferences for compatibility with older versions (<= 1.1.0)
    SharedPreferences prefs = await SharedPreferences.getInstance();
    try {
      firstCall = prefs.getBool(_firstCallSettingsKey);
    } on Exception {
      firstCall = true;
    }
  }
  firstCall ??= true;
  await _db.put(_firstCallSettingsKey, false);

  return firstCall;
}