diff --git a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart index 28ef3f08..0a8bb410 100644 --- a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart +++ b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart @@ -36,16 +36,15 @@ class _LocalProfileComponentWidgetState extends State LocalProfileComponentModel()); _model.setOnUpdate(onUpdate: () => setState(() {})); _model.setStateCallback = () => safeSetState(() {}); - - WidgetsBinding.instance.addPostFrameCallback((_) async{ - bool initialized = false; - bool isDevLinked = _model.cliUUID.isNotEmpty; - if(!isDevLinked && !initialized) { - initialized = true; - await LocalizationService.processLocals(context).then((value) => value == true ? onUpdate() : null); - } - }); + WidgetsBinding.instance.addPostFrameCallback((_) async { + bool initialized = false; + bool isDevLinked = _model.cliUUID.isNotEmpty; + if (!isDevLinked && !initialized) { + initialized = true; + await LocalizationService.processLocals(context).then((value) => value == true ? onUpdate() : null); + } + }); } @override @@ -99,7 +98,8 @@ class _LocalProfileComponentWidgetState extends State value == true ? onUpdate() : null); + await LocalizationService.processLocals(context) + .then((value) => value == true ? onUpdate() : null); }, child: ClipRRect( borderRadius: BorderRadius.circular(200.0), diff --git a/lib/main.dart b/lib/main.dart index c6564acf..24ebdf9b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -278,11 +278,10 @@ class _AppState extends State with WidgetsBindingObserver { @override void didChangeAppLifecycleState(AppLifecycleState state) async { - if (state == AppLifecycleState.detached) { await LocalizationService.processLocals(context); FirebaseMessagingService().updateDeviceToken(); - } + } } @override diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 1ed2deb1..062dcba4 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -28,7 +28,7 @@ class LocalizationService { if (isError == true) { _handleError(context, response.jsonBody['error_msg']); return; - } + } if (response.jsonBody == null) { final String errorMsg = FFLocalizations.of(context).getVariableText( enText: 'Verify your connection', @@ -76,7 +76,6 @@ class LocalizationService { return false; } - final List locals = response.jsonBody['locais'].toList() ?? []; _logLocalsStatus(locals); @@ -139,16 +138,14 @@ class LocalizationService { final String errorMsg = response.jsonBody['error_msg']; DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); return false; - } - else if (response.jsonBody == null) { + } else if (response.jsonBody == null) { final String errorMsg = FFLocalizations.of(context).getVariableText( enText: 'Verify your connection', ptText: 'Verifique sua conexão', ); DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); - return false ; - } - else { + return false; + } else { await _updateStorageUtil(response.jsonBody); return true; }