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'; import 'package:smoke_cess_app/widgets/buttons/round_button_widget.dart'; class SubmitFormButton extends StatelessWidget { final Future Function() submitCallback; final void Function() updateTasks; const SubmitFormButton( {super.key, required this.submitCallback, required this.updateTasks}); @override Widget build(BuildContext context) { PageProvider pageProvider = context.watch(); return Padding( padding: const EdgeInsets.symmetric(vertical: 16.0), child: RoundIconButton( onPressed: () async { int success = await submitCallback(); if (context.mounted) { if (success != 0) { await AwesomeDialog( context: context, dialogType: DialogType.success, title: 'Gespeichert', desc: 'Der Eintrag wurde erfolgreich gespeichert', ).show(); updateTasks(); pageProvider.swap(); } else { await AwesomeDialog( context: context, dialogType: DialogType.error, title: 'Fehler', desc: 'Der Eintrag konnte nicht gespeichert werden', ).show(); } } }, iconData: Icons.check_outlined, ), ); } }