poc fix fd-889
This commit is contained in:
parent
dce7d11a3e
commit
a1f42e1022
|
@ -14,6 +14,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||||
import 'package:hub/backend/notifications/notification_service.dart';
|
import 'package:hub/backend/notifications/notification_service.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'package:hub/flutter_flow/internationalization.dart';
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart';
|
import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart';
|
||||||
|
@ -115,7 +116,7 @@ class App extends StatefulWidget {
|
||||||
context.findAncestorStateOfType<_AppState>()!;
|
context.findAncestorStateOfType<_AppState>()!;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AppState extends State<App> {
|
class _AppState extends State<App> with WidgetsBindingObserver {
|
||||||
Locale? _locale = FFLocalizations.getStoredLocale();
|
Locale? _locale = FFLocalizations.getStoredLocale();
|
||||||
ThemeMode _themeMode = FlutterFlowTheme.themeMode;
|
ThemeMode _themeMode = FlutterFlowTheme.themeMode;
|
||||||
late AppStateNotifier _appStateNotifier;
|
late AppStateNotifier _appStateNotifier;
|
||||||
|
@ -262,9 +263,9 @@ class _AppState extends State<App> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override void initState() {
|
||||||
void initState() {
|
|
||||||
super.initState();
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addObserver(this);
|
||||||
|
|
||||||
log('DeviceUtil: ${DeviceUtil.getDeviceOSVersion()}');
|
log('DeviceUtil: ${DeviceUtil.getDeviceOSVersion()}');
|
||||||
|
|
||||||
|
@ -278,14 +279,21 @@ class _AppState extends State<App> {
|
||||||
WidgetsBinding.instance.addPersistentFrameCallback((_) => initDeepLinks());
|
WidgetsBinding.instance.addPersistentFrameCallback((_) => initDeepLinks());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override void dispose() {
|
||||||
void dispose() {
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
_linkSubscription?.cancel();
|
_linkSubscription?.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override void didChangeAppLifecycleState(AppLifecycleState state) async {
|
||||||
Widget build(BuildContext context) {
|
if (state == AppLifecycleState.resumed) {
|
||||||
|
|
||||||
|
await StorageUtil().ensureInitialization();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override Widget build(BuildContext context) {
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
key: navigatorKey,
|
key: navigatorKey,
|
||||||
title: 'FRE ACCESS HUB',
|
title: 'FRE ACCESS HUB',
|
||||||
|
|
|
@ -30,14 +30,13 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
_localProfileComponentWidget = LocalProfileComponentWidget();
|
_localProfileComponentWidget = LocalProfileComponentWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override void dispose() {
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
_model.dispose();
|
_model.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override void initState() {
|
||||||
void initState() {
|
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_model = createModel(context, () => HomePageModel());
|
_model = createModel(context, () => HomePageModel());
|
||||||
|
@ -49,8 +48,9 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
_model.textFieldFocusNode ??= FocusNode();
|
_model.textFieldFocusNode ??= FocusNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
|
@override Widget build(BuildContext context) {
|
||||||
StorageUtil().context = context;
|
StorageUtil().context = context;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: scaffoldKey,
|
key: scaffoldKey,
|
||||||
|
@ -109,6 +109,10 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Container buildPage(BuildContext context) {
|
Container buildPage(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
|
@ -22,10 +22,8 @@ class ReceptionPageWidget extends StatefulWidget {
|
||||||
State<ReceptionPageWidget> createState() => _ReceptionPageWidgetState();
|
State<ReceptionPageWidget> createState() => _ReceptionPageWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ReceptionPageWidgetState extends State<ReceptionPageWidget>
|
class _ReceptionPageWidgetState extends State<ReceptionPageWidget> with WidgetsBindingObserver {
|
||||||
with WidgetsBindingObserver {
|
@override void initState() {
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
() async {
|
() async {
|
||||||
|
@ -37,19 +35,13 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget>
|
||||||
LocalizationService.checkLocals(context);
|
LocalizationService.checkLocals(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override void dispose() {
|
||||||
void dispose() {
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
WidgetsBinding.instance
|
|
||||||
.removeObserver(this); // Remove a classe como observador
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
||||||
log('() => state: $state');
|
log('() => state: $state');
|
||||||
if (state == AppLifecycleState.resumed) {
|
if (state == AppLifecycleState.resumed) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
|
@ -58,7 +58,7 @@ class SecureStorageHelper extends ChangeNotifier implements Storage {
|
||||||
return value == 'true';
|
return value == 'true';
|
||||||
}
|
}
|
||||||
log('SecureStorageHelper -> getBool $value for key: $key');
|
log('SecureStorageHelper -> getBool $value for key: $key');
|
||||||
return value;
|
return value == 'true' || value == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuildContext?> getObject(String key) async {
|
Future<BuildContext?> getObject(String key) async {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
import 'dart:ffi';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hub/shared/helpers/secure_storage_helper.dart';
|
import 'package:hub/shared/helpers/secure_storage_helper.dart';
|
||||||
|
@ -37,6 +38,7 @@ class StorageUtil {
|
||||||
late final SQLiteStorageHelper _sqliteStorage;
|
late final SQLiteStorageHelper _sqliteStorage;
|
||||||
late final SecureStorageHelper _secureStorage;
|
late final SecureStorageHelper _secureStorage;
|
||||||
late final SharedPreferencesStorageHelper _sharedPreferences;
|
late final SharedPreferencesStorageHelper _sharedPreferences;
|
||||||
|
bool _initialized = true;
|
||||||
|
|
||||||
static Future<void> set(StorageData data) async {
|
static Future<void> set(StorageData data) async {
|
||||||
try {
|
try {
|
||||||
|
@ -119,13 +121,15 @@ class StorageUtil {
|
||||||
|
|
||||||
Future<void> ensureInitialization() async {
|
Future<void> ensureInitialization() async {
|
||||||
try {
|
try {
|
||||||
_sqliteStorage = SQLiteStorageHelper();
|
log('StorageUtil: Starting initialization');
|
||||||
_secureStorage = SecureStorageHelper();
|
|
||||||
_sharedPreferences = SharedPreferencesStorageHelper();
|
|
||||||
|
|
||||||
await initSharedPreferences();
|
await initSharedPreferences();
|
||||||
await initSecureStorage();
|
await initSecureStorage();
|
||||||
await initSQLiteStorage();
|
await initSQLiteStorage();
|
||||||
|
_initialized = false;
|
||||||
|
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
log('Error initializing storage: $e');
|
log('Error initializing storage: $e');
|
||||||
LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'StorageUtil', e, s);
|
LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'StorageUtil', e, s);
|
||||||
|
@ -134,6 +138,7 @@ class StorageUtil {
|
||||||
|
|
||||||
Future<void> initSharedPreferences() async {
|
Future<void> initSharedPreferences() async {
|
||||||
try {
|
try {
|
||||||
|
if(_initialized) _sharedPreferences = SharedPreferencesStorageHelper();
|
||||||
_sharedPreferences.prefs ??= await SharedPreferences.getInstance();
|
_sharedPreferences.prefs ??= await SharedPreferences.getInstance();
|
||||||
final bool milestone =
|
final bool milestone =
|
||||||
_sharedPreferences.prefs?.getBool('fre_isFirstRun') ?? true;
|
_sharedPreferences.prefs?.getBool('fre_isFirstRun') ?? true;
|
||||||
|
@ -156,6 +161,7 @@ class StorageUtil {
|
||||||
Future<void> initSecureStorage() async {
|
Future<void> initSecureStorage() async {
|
||||||
log('SecureStorageHelper: Starting initialization');
|
log('SecureStorageHelper: Starting initialization');
|
||||||
try {
|
try {
|
||||||
|
if(_initialized) _secureStorage = SecureStorageHelper();
|
||||||
_email = await _secureStorage.getString('fre_email');
|
_email = await _secureStorage.getString('fre_email');
|
||||||
_passwd = await _secureStorage.getString('fre_passwd');
|
_passwd = await _secureStorage.getString('fre_passwd');
|
||||||
_deviceType = await _secureStorage.getString('fre_deviceType');
|
_deviceType = await _secureStorage.getString('fre_deviceType');
|
||||||
|
@ -178,6 +184,7 @@ class StorageUtil {
|
||||||
Future<void> initSQLiteStorage() async {
|
Future<void> initSQLiteStorage() async {
|
||||||
log('SQLiteStorageHelper: Starting initialization');
|
log('SQLiteStorageHelper: Starting initialization');
|
||||||
try {
|
try {
|
||||||
|
if(_initialized) _sqliteStorage = SQLiteStorageHelper();
|
||||||
await _sqliteStorage.database;
|
await _sqliteStorage.database;
|
||||||
_devUUID = await _sqliteStorage.get('fre_devUUID') ?? '';
|
_devUUID = await _sqliteStorage.get('fre_devUUID') ?? '';
|
||||||
_userUUID = await _sqliteStorage.get('fre_userUUID') ?? '';
|
_userUUID = await _sqliteStorage.get('fre_userUUID') ?? '';
|
||||||
|
@ -187,8 +194,7 @@ class StorageUtil {
|
||||||
_cliUUID = await _sqliteStorage.get('fre_cliUUID') ?? '';
|
_cliUUID = await _sqliteStorage.get('fre_cliUUID') ?? '';
|
||||||
_ownerUUID = await _sqliteStorage.get('fre_ownerUUID') ?? '';
|
_ownerUUID = await _sqliteStorage.get('fre_ownerUUID') ?? '';
|
||||||
_cliName = await _sqliteStorage.get('fre_cliName') ?? '';
|
_cliName = await _sqliteStorage.get('fre_cliName') ?? '';
|
||||||
_petAmountRegister =
|
_petAmountRegister = await _sqliteStorage.get('fre_petAmountRegister') ?? '';
|
||||||
await _sqliteStorage.get('fre_petAmountRegister') ?? '';
|
|
||||||
_whatsapp = await _sqliteStorage.getBoolean('fre_whatsapp');
|
_whatsapp = await _sqliteStorage.getBoolean('fre_whatsapp');
|
||||||
_provisional = await _sqliteStorage.getBoolean('fre_provisional');
|
_provisional = await _sqliteStorage.getBoolean('fre_provisional');
|
||||||
_pets = await _sqliteStorage.getBoolean('fre_pets');
|
_pets = await _sqliteStorage.getBoolean('fre_pets');
|
||||||
|
|
Loading…
Reference in New Issue