diff --git a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart index 0c68525e..1fd0f164 100644 --- a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart +++ b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart @@ -14,8 +14,8 @@ import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_theme.dart'; class BottomArrowLinkedLocalsComponentWidget extends StatefulWidget { - const BottomArrowLinkedLocalsComponentWidget({super.key, required this.response}); - final ApiCallResponse? response; + BottomArrowLinkedLocalsComponentWidget({super.key, required this.response}); + ApiCallResponse? response; @override State createState() => _BottomArrowLinkedLocalsComponentWidgetState(); @@ -72,6 +72,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State _fetchLocals() async { try { setState(() => _loading = true); + widget.response = await PhpGroup.getLocalsCall.call(); final bool isError = widget.response?.jsonBody['error']; if (isError) { @@ -198,7 +199,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State { - late final String devUUID; - late final String userUUID; - late final String cliUUID; - late final String petAmountRegister; + late String devUUID = ''; + late String userUUID = ''; + late String cliUUID = ''; + late String petAmountRegister = '0'; dynamic item; late final TabController tabBarController; @@ -111,13 +111,17 @@ class PetsPageModel extends FlutterFlowModel { ); dropDownValueController1 = FormFieldController(dropDownValue1 ??= defaultDropDownText); dropDownValueController2 = FormFieldController(dropDownValue2 ??= defaultDropDownText); + log('() => ): $devUUID'); - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - petAmountRegister = (await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage)) ?? ''; + WidgetsBinding.instance.addPostFrameCallback((_) async { + devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? ''; + userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? ''; + cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage) ?? ''; + petAmountRegister = await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage) ?? ''; + }); safeSetState?.call(); + log('() => ): $devUUID'); } @override diff --git a/lib/pages/pets_page/pets_page_widget.dart b/lib/pages/pets_page/pets_page_widget.dart index 0bccf1e3..a0953d77 100644 --- a/lib/pages/pets_page/pets_page_widget.dart +++ b/lib/pages/pets_page/pets_page_widget.dart @@ -35,6 +35,7 @@ class _PetsPageWidgetState extends State with SingleTickerProvid void initState() { super.initState(); _model = createModel(context, () => PetsPageModel()); + _model.updateOnChange = true; _model.onUpdatePet = () { diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index e8c44c87..48c92848 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -131,19 +131,23 @@ class LocalizationService { static Future processData(BuildContext context) async { try { final GetDadosCall callback = PhpGroup.getDadosCall; - var response = await callback.call(); + ApiCallResponse? response = await callback.call(); final bool? isError = response.jsonBody['error']; - if (isError == true || isError == 'true') { + if (isError == true) { + final GetLocalsCall callback = PhpGroup.getLocalsCall; + response = await callback.call(); final String errorMsg = response.jsonBody['error_msg']; - DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); + await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); return false; } else if (response.jsonBody == null) { + final GetLocalsCall callback = PhpGroup.getLocalsCall; + response = await callback.call(); final String errorMsg = FFLocalizations.of(context).getVariableText( enText: 'Verify your connection', ptText: 'Verifique sua conexão', ); - DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); + await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); return false; } else { await _updateStorageUtil(response.jsonBody); @@ -337,4 +341,3 @@ class LocalizationService { await StorageHelper().set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage); } } -