From f62cdd254329ff02f886e1ae9065a9bbb86f5f2d Mon Sep 17 00:00:00 2001 From: "k.mannweiler" <2012491@stud.hs-mannheim.de> Date: Fri, 3 Mar 2023 12:51:48 +0100 Subject: [PATCH] On successful submit go back to view page --- lib/widgets/submit_form_button.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/widgets/submit_form_button.dart b/lib/widgets/submit_form_button.dart index b5bb593..4c98c34 100644 --- a/lib/widgets/submit_form_button.dart +++ b/lib/widgets/submit_form_button.dart @@ -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 Function() submitCallback; @@ -9,21 +11,23 @@ class SubmitFormButton extends StatelessWidget { @override Widget build(BuildContext context) { + PageProvider pageProvider = context.watch(); 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',