cpd_2022_zi/lib/widgets/submit_form_button.dart

39 lines
1.2 KiB
Dart

import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
class SubmitFormButton extends StatelessWidget {
final Future<int> Function() submitCallback;
final void Function() updateTasks;
const SubmitFormButton(
{super.key, required this.submitCallback, required this.updateTasks});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ElevatedButton(
onPressed: () async {
int success = await submitCallback();
if (success != 0) {
AwesomeDialog(
context: context,
dialogType: DialogType.success,
title: 'Gespeichert',
desc: 'Der Eintrag wurde erfolgreich gespeichert',
).show();
updateTasks();
} else {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
title: 'Fehler',
desc: 'Der Eintrag konnte nicht gespeichert werden',
).show();
}
},
child: const Text('Speichern'),
),
);
}
}