WIP
This commit is contained in:
parent
194db60045
commit
48e8a1a5cb
|
@ -4,6 +4,7 @@ import 'package:csv/csv.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
|
||||
class AppState extends ChangeNotifier {
|
||||
|
@ -71,6 +72,7 @@ class AppState extends ChangeNotifier {
|
|||
|
||||
Future initializePersistedState() async {
|
||||
secureStorage = const FlutterSecureStorage();
|
||||
|
||||
await _safeInitAsync(() async {
|
||||
_cliUUID = await secureStorage.getString('ff_cliUUID') ?? _cliUUID;
|
||||
});
|
||||
|
@ -177,6 +179,7 @@ class AppState extends ChangeNotifier {
|
|||
await secureStorage.getBool('ff_request_os_notification') ??
|
||||
_isRequestOSNotification;
|
||||
});
|
||||
await loadFirstRun();
|
||||
}
|
||||
|
||||
void update(VoidCallback callback) {
|
||||
|
@ -186,6 +189,29 @@ class AppState extends ChangeNotifier {
|
|||
|
||||
late FlutterSecureStorage secureStorage;
|
||||
|
||||
bool _firstRun = true;
|
||||
bool get firstRun => _firstRun;
|
||||
|
||||
Future<void> loadFirstRun() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_firstRun = prefs.getBool('first_run') ?? true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> setFirstRun(bool value) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_firstRun = value;
|
||||
await prefs.setBool('first_run', value);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> deleteFirstRun() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_firstRun = true;
|
||||
await prefs.remove('first_run');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int _petAmountRegister = 0;
|
||||
int get petAmountRegister => _petAmountRegister;
|
||||
set petAmountRegister(int value) {
|
||||
|
|
|
@ -28,6 +28,8 @@ Future<void> initializeApp() async {
|
|||
final appState = AppState();
|
||||
await appState.initializePersistedState();
|
||||
|
||||
if (AppState().firstRun == true) AppState().setFirstRun(false);
|
||||
|
||||
await Firebase.initializeApp();
|
||||
await NotificationService.initialize();
|
||||
|
||||
|
|
Loading…
Reference in New Issue