jld3103
2 years ago
9 changed files with 81 additions and 7 deletions
@ -0,0 +1,30 @@ |
|||||||
|
part of '../neon.dart'; |
||||||
|
|
||||||
|
abstract class FirstLaunchBlocEvents {} |
||||||
|
|
||||||
|
abstract class FirstLaunchBlocStates { |
||||||
|
BehaviorSubject get onFirstLaunch; |
||||||
|
} |
||||||
|
|
||||||
|
class FirstLaunchBloc extends Bloc implements FirstLaunchBlocEvents, FirstLaunchBlocStates { |
||||||
|
FirstLaunchBloc( |
||||||
|
this._sharedPreferences, { |
||||||
|
final bool disabled = false, |
||||||
|
}) { |
||||||
|
if (!disabled && !_sharedPreferences.containsKey(_keyFirstLaunch)) { |
||||||
|
onFirstLaunch.add(null); |
||||||
|
unawaited(_sharedPreferences.setBool(_keyFirstLaunch, false)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
final SharedPreferences _sharedPreferences; |
||||||
|
final _keyFirstLaunch = 'first-launch'; |
||||||
|
|
||||||
|
@override |
||||||
|
void dispose() { |
||||||
|
unawaited(onFirstLaunch.close()); |
||||||
|
} |
||||||
|
|
||||||
|
@override |
||||||
|
BehaviorSubject onFirstLaunch = BehaviorSubject(); |
||||||
|
} |
Loading…
Reference in new issue