Refactor liberation history widget button callbacks

This commit is contained in:
jantunesmesias 2024-08-21 15:20:53 -03:00
parent f27fc073ea
commit ae5cf350ad
1 changed files with 42 additions and 24 deletions

View File

@ -228,14 +228,15 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
),
icon: const Icon(Icons.done),
onPressed: () async {
return answersRequest.call(
return answersRequest
.call(
context,
liberationHistoryItem['NOT_ID'].toString(),
'L',
'',
liberationHistoryItem['VTE_ID'].toString(),
);
)
.then((message) {
if (message.isEmpty) {
showSnackbar(
context,
@ -246,6 +247,14 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
} else {
showSnackbar(context, message, true);
}
safeSetState(() {
_requestWrap = [];
_requestFuture = _fetchRequests();
});
Navigator.pop(context);
});
},
),
if (liberationHistoryItem['NOT_STATUS'] == 'S')
@ -266,14 +275,15 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
),
icon: const Icon(Icons.close),
onPressed: () async {
return answersRequest.call(
return answersRequest
.call(
context,
liberationHistoryItem['NOT_ID'].toString(),
'B',
'',
liberationHistoryItem['VTE_ID'].toString(),
);
)
.then((message) {
if (message.isEmpty) {
showSnackbar(
context,
@ -284,6 +294,14 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
} else {
showSnackbar(context, message, true);
}
safeSetState(() {
_requestWrap = [];
_requestFuture = _fetchRequests();
});
Navigator.pop(context);
});
},
)
],