From d6c5f50a78076519428b1fb5e2156ded612c1092 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Wed, 23 Oct 2024 11:41:40 -0300 Subject: [PATCH 1/4] hotfix lifecyclestates --- lib/main.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index a4358e0e..4fa58c7c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -287,9 +287,8 @@ class _AppState extends State with WidgetsBindingObserver { } @override void didChangeAppLifecycleState(AppLifecycleState state) async { - if (state == AppLifecycleState.resumed) await StorageUtil().ensureInitialization(); - if (state == AppLifecycleState.resumed) LocalizationService.processLocals(context); - else LocalizationService.processData(context); + await StorageUtil().ensureInitialization(); + LocalizationService.processLocals(context); } @override Widget build(BuildContext context) { From 6c71fd8f935cd799cd93e31252f6e1bbd09a4c5d Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Wed, 23 Oct 2024 12:42:58 -0300 Subject: [PATCH 2/4] WIP --- .../menu_component/menu_component_model.dart | 35 ++++++++++--------- lib/main.dart | 5 +-- .../localization/localization_service.dart | 16 ++++++--- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/lib/components/organism_components/menu_component/menu_component_model.dart b/lib/components/organism_components/menu_component/menu_component_model.dart index e6f7c1cb..3e89cf99 100644 --- a/lib/components/organism_components/menu_component/menu_component_model.dart +++ b/lib/components/organism_components/menu_component/menu_component_model.dart @@ -5,6 +5,7 @@ import 'package:hub/shared/extensions/dialog_extensions.dart'; import 'package:hub/shared/services/authentication/authentication_service.dart'; import 'package:hub/shared/utils/storage_util.dart'; +import '../../../shared/services/localization/localization_service.dart'; import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart'; import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -42,7 +43,9 @@ class MenuComponentModel extends FlutterFlowModel { isGrid = !isGrid; } - Future isChecked() async { + Future isChecked(BuildContext context) async { + await StorageUtil().ensureInitialization(); + await LocalizationService.processLocals(context); return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty && StorageUtil().devUUID.isNotEmpty && @@ -50,7 +53,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openQRCodeScanner(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/qrCodePage', @@ -69,7 +72,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openCompleteSchedule(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/scheduleCompleteVisitPage', @@ -90,7 +93,7 @@ class MenuComponentModel extends FlutterFlowModel { Future openDeliverySchedule(BuildContext context) async { final bool isProvisional = StorageUtil().provisional; - isChecked().then((value) { + isChecked(context).then((value) { if (value) { if (isProvisional == true) { context.push( @@ -115,7 +118,7 @@ class MenuComponentModel extends FlutterFlowModel { Future openProvisionalSchedule(BuildContext context) async { final isProvisional = StorageUtil().provisional; - isChecked().then((value) { + isChecked(context).then((value) { if (value) { if (isProvisional == true) { context.push( @@ -140,7 +143,7 @@ class MenuComponentModel extends FlutterFlowModel { Future openFastPassSchedule(BuildContext context) async { final isWpp = StorageUtil().whatsapp; - isChecked().then((value) { + isChecked(context).then((value) { if (value) { if (isWpp) { context.push( @@ -204,7 +207,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openVisitorsRegister(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/registerVisitorPage', @@ -223,7 +226,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openPoepleOnTheProperty(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/peopleOnThePropertyPage', @@ -258,7 +261,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openPreferencesSettings(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/preferencesSettings', @@ -279,7 +282,7 @@ class MenuComponentModel extends FlutterFlowModel { Future openMyOrders(BuildContext context) async { final isWpp = StorageUtil().whatsapp; - isChecked().then((value) { + isChecked(context).then((value) { if (value) { if (isWpp) { context.push( @@ -304,7 +307,7 @@ class MenuComponentModel extends FlutterFlowModel { Future openReservations(BuildContext context) async { final isWpp = StorageUtil().whatsapp; - isChecked().then((value) { + isChecked(context).then((value) { if (value) { if (isWpp) { context.push( @@ -373,7 +376,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openLiberationsHistory(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/liberationHistory', @@ -392,7 +395,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openAccessHistory(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/acessHistoryPage', @@ -411,7 +414,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openVisitsHistory(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/scheduleCompleteVisitPage', @@ -430,7 +433,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openMessagesHistory(BuildContext context) async { - isChecked().then((value) { + isChecked(context).then((value) { if (value) { context.push( '/messageHistoryPage', @@ -451,7 +454,7 @@ class MenuComponentModel extends FlutterFlowModel { Future openPetsRegister(BuildContext context) async { bool isPet = StorageUtil().pets; - isChecked().then((value) { + isChecked(context).then((value) { if (value) { if (isPet) { context.push( diff --git a/lib/main.dart b/lib/main.dart index 4fa58c7c..f6f7822f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -287,8 +287,9 @@ class _AppState extends State with WidgetsBindingObserver { } @override void didChangeAppLifecycleState(AppLifecycleState state) async { - await StorageUtil().ensureInitialization(); - LocalizationService.processLocals(context); + if (state == AppLifecycleState.resumed) await StorageUtil().ensureInitialization(); + if (state == AppLifecycleState.resumed) await LocalizationService.processLocals(context); + else LocalizationService.processData(context); } @override Widget build(BuildContext context) { diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 2b924722..5115ba4b 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -99,7 +99,13 @@ class LocalizationService { } catch (e, s) { log('() => stack: $s'); log('() => catch: $e', stackTrace: s); - return await selectLocal(context); + // return await selectLocal(context); + final String errorMsg = FFLocalizations.of(context).getVariableText( + enText: 'Error getting locals, verify your connection', + ptText: 'Erro ao obter locais, verifique sua conexão', + ); + DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context)); + return false; } } static Future processData(BuildContext context) async { @@ -119,7 +125,11 @@ class LocalizationService { } catch (e, s) { log('() => stack processData: $s'); log('() => error processData: $e', stackTrace: s); - DialogUtil.warningDefault(context).whenComplete(() => selectLocal(context)); + final String errorMsg = FFLocalizations.of(context).getVariableText( + enText: 'Error getting data, verify your connection', + ptText: 'Erro ao obter dados, verifique sua conexão', + ); + DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context)); return false; } } @@ -225,7 +235,6 @@ class LocalizationService { log('() => CLU_STATUS: $status'); } } - static bool _isActive(List locals) { return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty; } @@ -244,7 +253,6 @@ class LocalizationService { static bool _isAvailable() { return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty; } - static void _updateStorageUtil(Map jsonBody) { final bool whatsapp = jsonBody['whatsapp'] ?? false; final bool provisional = jsonBody['provisional'] ?? false; From 6b4f2ffc3f6f4e0c9d64804be441c2d9b4b9e64d Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Wed, 23 Oct 2024 14:45:47 -0300 Subject: [PATCH 3/4] =?UTF-8?q?FIX:=20resolu=C3=A7=C3=A3o=20do=20bug=20de?= =?UTF-8?q?=20unavailableFeature=20ap=C3=B3s=20lock=20do=20OS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menu_button_item_widget.dart | 27 ++- .../menu_card_item/menu_card_item.dart | 20 ++- .../menu_component/menu_component_model.dart | 163 ++---------------- lib/main.dart | 5 +- .../localization/localization_service.dart | 33 ++-- lib/shared/utils/storage_util.dart | 20 +-- 6 files changed, 76 insertions(+), 192 deletions(-) diff --git a/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart b/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart index c1954b20..44724d64 100644 --- a/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart +++ b/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart @@ -5,6 +5,9 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/storage_util.dart'; +import '../../../shared/extensions/dialog_extensions.dart'; +import '../../../shared/services/localization/localization_service.dart'; + class MenuButtonWidget extends MenuEntry { const MenuButtonWidget({ @@ -27,6 +30,8 @@ class MenuButtonWidget extends MenuEntry { class _MenuButtonWidgetState extends State { get action => action; + bool _isProcessing = false; + @override Widget build(BuildContext context) { @@ -35,14 +40,20 @@ class _MenuButtonWidgetState extends State { focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, - onTap: () async { - final cliUUID = StorageUtil().cliUUID; - - if (cliUUID.isEmpty) { - return DialogUtil.warningDefault(context); - } else { - await widget.action?.call(); - } + onTap: _isProcessing ? null : () async { + setState(() { + _isProcessing = true; + }); + await LocalizationService.processLocals(context).then((value) async { + if (value) { + await widget.action?.call(); + } else { + DialogUnavailable.unavailableCredentials(context); + } + }); + setState(() { + _isProcessing = false; + }); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0), diff --git a/lib/components/atomic_components/menu_card_item/menu_card_item.dart b/lib/components/atomic_components/menu_card_item/menu_card_item.dart index 4c68066e..04398e5c 100644 --- a/lib/components/atomic_components/menu_card_item/menu_card_item.dart +++ b/lib/components/atomic_components/menu_card_item/menu_card_item.dart @@ -3,6 +3,9 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import '../../../shared/extensions/dialog_extensions.dart'; +import '../../../shared/services/localization/localization_service.dart'; + class MenuCardItem extends MenuEntry { const MenuCardItem({ super.key, @@ -24,6 +27,7 @@ class MenuCardItem extends MenuEntry { class _MenuCardItemState extends State { get action => action; + bool _isProcessing = false; @override Widget build(BuildContext context) { @@ -32,8 +36,20 @@ class _MenuCardItemState extends State { focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, - onTap: () async { - await widget.action?.call(); + onTap: _isProcessing ? null : () async { + setState(() { + _isProcessing = true; + }); + await LocalizationService.processLocals(context).then((value) async { + if (value) { + await widget.action?.call(); + } else { + DialogUnavailable.unavailableCredentials(context); + } + }); + setState(() { + _isProcessing = false; + }); }, child: Card( elevation: 0, diff --git a/lib/components/organism_components/menu_component/menu_component_model.dart b/lib/components/organism_components/menu_component/menu_component_model.dart index 3e89cf99..7b4934f1 100644 --- a/lib/components/organism_components/menu_component/menu_component_model.dart +++ b/lib/components/organism_components/menu_component/menu_component_model.dart @@ -12,49 +12,27 @@ import '/flutter_flow/flutter_flow_util.dart'; import 'menu_component_widget.dart' show MenuComponentWidget; class MenuComponentModel extends FlutterFlowModel { - /// Local state fields for this component. bool isGrid = false; - /// State fields for stateful widgets in this component. - - // Model for menuListViewComponent. late MenuListViewComponentModel menuListViewComponentModel; - - // Model for menuStaggeredViewComponent. late MenuStaggeredViewComponentModel menuStaggeredViewComponentModel; - @override - void initState(BuildContext context) { + @override void initState(BuildContext context) { menuListViewComponentModel = createModel(context, () => MenuListViewComponentModel()); menuStaggeredViewComponentModel = createModel(context, () => MenuStaggeredViewComponentModel()); } - - @override - void dispose() { + @override void dispose() { menuListViewComponentModel.dispose(); menuStaggeredViewComponentModel.dispose(); } - /// Action blocks. Future changeMenuStyle(BuildContext context) async { isGrid = !isGrid; } - - Future isChecked(BuildContext context) async { - await StorageUtil().ensureInitialization(); - await LocalizationService.processLocals(context); - return StorageUtil().cliUUID.isNotEmpty && - StorageUtil().cliName.isNotEmpty && - StorageUtil().devUUID.isNotEmpty && - StorageUtil().userUUID.isNotEmpty; - } - Future openQRCodeScanner(BuildContext context) async { - isChecked(context).then((value) { - if (value) { context.push( '/qrCodePage', extra: { @@ -65,36 +43,21 @@ class MenuComponentModel extends FlutterFlowModel { ), }, ); - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future openCompleteSchedule(BuildContext context) async { - isChecked(context).then((value) { - if (value) { - context.push( - '/scheduleCompleteVisitPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableCredentials(context); - } - }); + context.push( + '/scheduleCompleteVisitPage', + extra: { + kTransitionInfoKey: const TransitionInfo( + hasTransition: true, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }, + ); } - Future openDeliverySchedule(BuildContext context) async { final bool isProvisional = StorageUtil().provisional; - - isChecked(context).then((value) { - if (value) { if (isProvisional == true) { context.push( '/deliverySchedule', @@ -109,17 +72,9 @@ class MenuComponentModel extends FlutterFlowModel { } else { DialogUnavailable.unavailableFeature(context); } - } else { - DialogUnavailable.unavailableCredentials(context); - } - }); - } - + } Future openProvisionalSchedule(BuildContext context) async { final isProvisional = StorageUtil().provisional; - - isChecked(context).then((value) { - if (value) { if (isProvisional == true) { context.push( '/provisionalSchedule', @@ -134,17 +89,9 @@ class MenuComponentModel extends FlutterFlowModel { } else { DialogUnavailable.unavailableFeature(context); } - } else { - DialogUnavailable.unavailableCredentials(context); - } - }); } - Future openFastPassSchedule(BuildContext context) async { final isWpp = StorageUtil().whatsapp; - - isChecked(context).then((value) { - if (value) { if (isWpp) { context.push( '/fastPassPage', @@ -159,12 +106,7 @@ class MenuComponentModel extends FlutterFlowModel { } else { DialogUnavailable.unavailableFeature(context); } - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future showSchedules(BuildContext context) async { final routesListStr = [ 'scheduleProvisionalVisitPage', @@ -190,7 +132,6 @@ class MenuComponentModel extends FlutterFlowModel { enText: 'Complete\nSchedule', ), ]; - await showAdaptiveDialog( context: context, builder: (context) { @@ -205,10 +146,7 @@ class MenuComponentModel extends FlutterFlowModel { }, ); } - Future openVisitorsRegister(BuildContext context) async { - isChecked(context).then((value) { - if (value) { context.push( '/registerVisitorPage', extra: { @@ -219,15 +157,8 @@ class MenuComponentModel extends FlutterFlowModel { ), }, ); - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future openPoepleOnTheProperty(BuildContext context) async { - isChecked(context).then((value) { - if (value) { context.push( '/peopleOnThePropertyPage', extra: { @@ -238,12 +169,7 @@ class MenuComponentModel extends FlutterFlowModel { ), }, ); - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future Logout(BuildContext context) async { final String title = FFLocalizations.of(context).getVariableText( ptText: 'Sair', @@ -259,10 +185,7 @@ class MenuComponentModel extends FlutterFlowModel { content, () async => await AuthenticationService.signOut(context)); } - Future openPreferencesSettings(BuildContext context) async { - isChecked(context).then((value) { - if (value) { context.push( '/preferencesSettings', extra: { @@ -273,17 +196,9 @@ class MenuComponentModel extends FlutterFlowModel { ), }, ); - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future openMyOrders(BuildContext context) async { final isWpp = StorageUtil().whatsapp; - - isChecked(context).then((value) { - if (value) { if (isWpp) { context.push( '/packageOrder', @@ -298,17 +213,9 @@ class MenuComponentModel extends FlutterFlowModel { } else { DialogUnavailable.unavailableFeature(context); } - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future openReservations(BuildContext context) async { final isWpp = StorageUtil().whatsapp; - - isChecked(context).then((value) { - if (value) { if (isWpp) { context.push( '/reservation', @@ -323,12 +230,7 @@ class MenuComponentModel extends FlutterFlowModel { } else { DialogUnavailable.unavailableFeature(context); } - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future showHistories(BuildContext context) async { await showAdaptiveDialog( // isScrollControlled: true, @@ -374,10 +276,7 @@ class MenuComponentModel extends FlutterFlowModel { }, ); } - Future openLiberationsHistory(BuildContext context) async { - isChecked(context).then((value) { - if (value) { context.push( '/liberationHistory', extra: { @@ -388,15 +287,8 @@ class MenuComponentModel extends FlutterFlowModel { ), }, ); - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future openAccessHistory(BuildContext context) async { - isChecked(context).then((value) { - if (value) { context.push( '/acessHistoryPage', extra: { @@ -407,15 +299,8 @@ class MenuComponentModel extends FlutterFlowModel { ), }, ); - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future openVisitsHistory(BuildContext context) async { - isChecked(context).then((value) { - if (value) { context.push( '/scheduleCompleteVisitPage', extra: { @@ -426,15 +311,8 @@ class MenuComponentModel extends FlutterFlowModel { ), }, ); - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future openMessagesHistory(BuildContext context) async { - isChecked(context).then((value) { - if (value) { context.push( '/messageHistoryPage', extra: { @@ -445,17 +323,9 @@ class MenuComponentModel extends FlutterFlowModel { ), }, ); - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } - Future openPetsRegister(BuildContext context) async { bool isPet = StorageUtil().pets; - - isChecked(context).then((value) { - if (value) { if (isPet) { context.push( '/petsPage', @@ -470,9 +340,8 @@ class MenuComponentModel extends FlutterFlowModel { } else { DialogUnavailable.unavailableFeature(context); } - } else { - DialogUnavailable.unavailableCredentials(context); } - }); - } + + } + diff --git a/lib/main.dart b/lib/main.dart index f6f7822f..9ebf0b17 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -287,9 +287,8 @@ class _AppState extends State with WidgetsBindingObserver { } @override void didChangeAppLifecycleState(AppLifecycleState state) async { - if (state == AppLifecycleState.resumed) await StorageUtil().ensureInitialization(); - if (state == AppLifecycleState.resumed) await LocalizationService.processLocals(context); - else LocalizationService.processData(context); + bool initialize = await StorageUtil().ensureInitialization(); + if(initialize) await LocalizationService.processLocals(context); } @override Widget build(BuildContext context) { diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 5115ba4b..089e005b 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -45,6 +45,7 @@ class LocalizationService { } static Future processLocals(BuildContext context) async { try { + await StorageUtil().ensureInitialization(); final GetLocalsCall callback = PhpGroup.getLocalsCall; final ApiCallResponse response = await callback.call(); final bool isError = response.jsonBody['error']; @@ -85,10 +86,8 @@ class LocalizationService { return await processData(context); } else if (isAvailable) { log('() => isAvailable'); - await StorageUtil().ensureInitialization(); return await processData(context); } else { - await StorageUtil().ensureInitialization(); if (!isUnique && !isActive) log('() => not unique and not active'); if (!isUnique && isInactived) log('() => not unique and inactived'); if (!isUnique && isPending) log('() => not unique and pending'); @@ -110,17 +109,19 @@ class LocalizationService { } static Future processData(BuildContext context) async { try { + await StorageUtil().ensureInitialization(); final GetDadosCall callback = PhpGroup.getDadosCall; var response = await callback.call(); - final error = response.jsonBody['error']; + final bool error = response.jsonBody['error']; - if (error == false) { + if (error == true || error == 'true') { + final String errorMsg = response.jsonBody['error_msg']; + DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context)); + return false; + } + else { _updateStorageUtil(response.jsonBody); return true; - } else { - log('() => error in processData: $error'); - DialogUtil.warningDefault(context).whenComplete(() => selectLocal(context)); - return false; } } catch (e, s) { log('() => stack processData: $s'); @@ -205,6 +206,7 @@ class LocalizationService { try { StorageUtil().cliUUID = locals[0]['CLI_ID']; StorageUtil().ownerUUID = locals[0]['CLU_OWNER_ID']; + StorageUtil().cliName = locals[0]['CLI_NOME']; var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); if (response.jsonBody['error'] == true) { StorageUtil().cliUUID = ''; @@ -254,16 +256,11 @@ class LocalizationService { return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty; } static void _updateStorageUtil(Map jsonBody) { - final bool whatsapp = jsonBody['whatsapp'] ?? false; - final bool provisional = jsonBody['provisional'] ?? false; - final bool pets = jsonBody['pet'] ?? false; - final String petAmountRegister = jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString(); - final String name = jsonBody['visitado']['VDO_NOME']; - StorageUtil().whatsapp = whatsapp; - StorageUtil().provisional = provisional; - StorageUtil().pets = pets; - StorageUtil().petAmountRegister = petAmountRegister; - StorageUtil().userName = name; + StorageUtil().whatsapp = jsonBody['whatsapp'] ?? false; + StorageUtil().provisional = jsonBody['provisional'] ?? false; + StorageUtil().pets = jsonBody['pet'] ?? false; + StorageUtil().petAmountRegister = jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString(); + StorageUtil().userName = jsonBody['visitado']['VDO_NOME']; } diff --git a/lib/shared/utils/storage_util.dart b/lib/shared/utils/storage_util.dart index fa5c554b..43839dfe 100644 --- a/lib/shared/utils/storage_util.dart +++ b/lib/shared/utils/storage_util.dart @@ -119,20 +119,20 @@ class StorageUtil { } } - Future ensureInitialization() async { + Future ensureInitialization() async { try { log('StorageUtil: Starting initialization'); - - - + if(!_initialized) return true; await initSharedPreferences(); await initSecureStorage(); await initSQLiteStorage(); - _initialized = false; - + if(_initialized) _initialized = false; + if(_initialized) return true; + return false; } catch (e, s) { log('Error initializing storage: $e'); LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'StorageUtil', e, s); + return false; } } @@ -218,14 +218,6 @@ class StorageUtil { bool get isRecovered => _isRecovered; set isRecovered(bool value) => _isRecovered = value; - String _tempMail = ''; - String get tempMail => _tempMail; - set tempMail(String value) => _tempMail = value; - - String _tempToken = ''; - String get tempToken => _tempToken; - set tempToken(String value) => _tempToken = value; - bool _isFirstRun = true; bool get isFirstRun => _isFirstRun; set isFirstRun(bool value) { From 5a90337b6b478e24633b7d1866ab352ac57ac441 Mon Sep 17 00:00:00 2001 From: Ivan Antunes Date: Wed, 23 Oct 2024 15:27:22 -0300 Subject: [PATCH 4/4] release: 1.1.2+13 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index eae46f01..9ddc4690 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. publish_to: "none" -version: 1.1.1+11 +version: 1.1.2+13 environment: sdk: ">=3.0.0 <4.0.0"