isFirstRun static method
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 {
await _ensureInitialized();
bool? isFirstRun = _db.get(_firstRunSettingsKey);
if (isFirstRun == null) {
// check in shared preferences for compatibility with older versions (<= 1.1.0)
SharedPreferences prefs = await SharedPreferences.getInstance();
try {
isFirstRun = prefs.getBool(_firstRunSettingsKey);
} on Exception {
isFirstRun = true;
}
}
isFirstRun ??= true;
await _db.put(_firstRunSettingsKey, false);
if (_isFirstRun == null) _isFirstRun = isFirstRun;
return isFirstRun;
}
}