On successful submit go back to view page

main
Kai Mannweiler 2023-03-03 12:51:48 +01:00
parent 606e8c3f19
commit f62cdd2543
1 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,7 @@
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/providers/page_provider.dart';
class SubmitFormButton extends StatelessWidget {
final Future<int> Function() submitCallback;
@ -9,21 +11,23 @@ class SubmitFormButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
PageProvider pageProvider = context.watch<PageProvider>();
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ElevatedButton(
onPressed: () async {
int success = await submitCallback();
if (success != 0) {
AwesomeDialog(
await AwesomeDialog(
context: context,
dialogType: DialogType.success,
title: 'Gespeichert',
desc: 'Der Eintrag wurde erfolgreich gespeichert',
).show();
updateTasks();
pageProvider.swap();
} else {
AwesomeDialog(
await AwesomeDialog(
context: context,
dialogType: DialogType.error,
title: 'Fehler',