cpd_2022_zi/lib/widgets/submit_form_button.dart

34 lines
1.1 KiB
Dart
Raw Normal View History

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