diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index d24c4d29..1d400e40 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -218,29 +218,28 @@ class _LiberationHistoryWidgetState extends State { ), icon: const Icon(Icons.done), onPressed: () async { - Navigator.pop(context); - - safeSetState(() { - _requestWrap = []; - _requestFuture = _fetchRequests(); - }); - - var message = await answersRequest.call( + return answersRequest.call( context, liberationHistoryItem['NOT_ID'].toString(), 'L', '', liberationHistoryItem['VTE_ID'].toString(), - ); + ).then((message) { + if (message.isEmpty) { + showSnackbar( + context, + FFLocalizations.of(context).getVariableText(enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false); + } else { + showSnackbar(context, message, true); + } - if (message.isEmpty) { - showSnackbar( - context, - FFLocalizations.of(context).getVariableText(enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false); - } else { - showSnackbar(context, message, true); - } + safeSetState(() { + _requestWrap = []; + _requestFuture = _fetchRequests(); + }); + Navigator.pop(context); + }); }, ), if (liberationHistoryItem['NOT_STATUS'] == 'S') @@ -260,29 +259,28 @@ class _LiberationHistoryWidgetState extends State { ), icon: const Icon(Icons.close), onPressed: () async { - Navigator.pop(context); - - safeSetState(() { - _requestWrap = []; - _requestFuture = _fetchRequests(); - }); - - var message = await answersRequest.call( + return answersRequest.call( context, liberationHistoryItem['NOT_ID'].toString(), 'B', '', liberationHistoryItem['VTE_ID'].toString(), - ); + ).then((message) { + if (message.isEmpty) { + showSnackbar( + context, + FFLocalizations.of(context).getVariableText(enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false); + } else { + showSnackbar(context, message, true); + } - if (message.isEmpty) { - showSnackbar( - context, - FFLocalizations.of(context).getVariableText(enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false); - } else { - showSnackbar(context, message, true); - } + safeSetState(() { + _requestWrap = []; + _requestFuture = _fetchRequests(); + }); + Navigator.pop(context); + }); }, ) ],