isFirstRun static method

Future<bool> isFirstRun()

Returns true if this is the first time you call this method since installing the app, otherwise false.

In contrast to IsFirstRun.isFirstCall(), this method continues to return true as long as the app keeps running after the first call after installing the app, while IsFirstRun.isFirstCall() returns true only on the first call after installing the app.

Implementation

static Future<bool> isFirstRun() async {
  if (_isFirstRun != null) {
    return _isFirstRun!;
  } else {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    bool isFirstRun;
    try {
      isFirstRun = prefs.getBool(_firstRunSettingsKey) ?? true;
    } on Exception {
      isFirstRun = true;
    }
    await prefs.setBool(_firstRunSettingsKey, false);
    if (_isFirstRun == null) _isFirstRun = isFirstRun;
    return isFirstRun;
  }
}