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