FIX: internet connection exception in settings

This commit is contained in:
jantunesmesias 2024-08-06 17:36:29 -03:00
parent 87e092a070
commit cf79bff8e4
1 changed files with 86 additions and 40 deletions

View File

@ -273,15 +273,47 @@ class PreferencesPageModel with ChangeNotifier {
),
FFButtonWidget(
onPressed: () async {
PhpGroup.resopndeVinculo
.call(
userUUID: FFAppState().userUUID,
devUUID: FFAppState().devUUID,
cliID: FFAppState().cliUUID,
tarefa: 'I',
)
// ignore: body_might_complete_normally_catch_error
.catchError((err, stack) {
try {
await PhpGroup.resopndeVinculo
.call(
userUUID: FFAppState().userUUID,
devUUID: FFAppState().devUUID,
cliID: FFAppState().cliUUID,
tarefa: 'I',
)
// ignore: body_might_complete_normally_catch_error
.catchError((err, stack) {
log(err.toString());
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
FFLocalizations.of(context).getVariableText(
enText: 'Error unlinking device',
ptText: 'Erro ao desvincular dispositivo',
),
style: TextStyle(
color:
FlutterFlowTheme.of(context).info)),
backgroundColor:
FlutterFlowTheme.of(context).error,
duration: const Duration(seconds: 3),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
),
);
}).then(
(value) {
FFAppState().deleteCliUUID();
FFAppState().deleteLocal();
FFAppState().deleteOwnerUUID();
Navigator.pop(context);
Navigator.pop(context);
},
);
notifyListeners();
} catch (err, stack) {
log(err.toString());
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@ -300,16 +332,7 @@ class PreferencesPageModel with ChangeNotifier {
),
),
);
}).then(
(value) {
FFAppState().deleteCliUUID();
FFAppState().deleteLocal();
FFAppState().deleteOwnerUUID();
Navigator.pop(context);
Navigator.pop(context);
},
);
notifyListeners();
}
},
text: FFLocalizations.of(context).getVariableText(
enText: 'Unlink',
@ -381,26 +404,50 @@ class PreferencesPageModel with ChangeNotifier {
),
),
FFButtonWidget(
onPressed: () {
PhpGroup.deleteAccount
.call(
devUUID: FFAppState().devUUID,
userUUID: FFAppState().userUUID,
)
.then((value) {
FFAppState().deleteAll();
FFAppState().isLogged = false;
context.goNamed(
'welcomePage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
onPressed: () async {
try {
await PhpGroup.deleteAccount
.call(
devUUID: FFAppState().devUUID,
userUUID: FFAppState().userUUID,
)
.then((value) {
FFAppState().deleteAll();
FFAppState().isLogged = false;
context.goNamed(
'welcomePage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
}).catchError((err) {
log(err.toString());
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
FFLocalizations.of(context).getVariableText(
enText: 'Error deleting account',
ptText: 'Erro ao deletar conta',
),
style: TextStyle(
color:
FlutterFlowTheme.of(context).info)),
backgroundColor:
FlutterFlowTheme.of(context).error,
duration: const Duration(seconds: 3),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
),
},
);
}).catchError((err) {
);
});
notifyListeners();
} catch (err, stack) {
log(err.toString());
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@ -419,8 +466,7 @@ class PreferencesPageModel with ChangeNotifier {
),
),
);
});
notifyListeners();
}
},
options: FFButtonOptions(
width: MediaQuery.of(context).size.width * 0.3,