diff --git a/lib/AddPage.dart b/lib/AddPage.dart index 7049861..7172113 100644 --- a/lib/AddPage.dart +++ b/lib/AddPage.dart @@ -16,6 +16,7 @@ class _AddScreenState extends State { final _titleController = TextEditingController(); final _descriptionController = TextEditingController(); File? _imageFile; + bool _uploading = false; Future _getImage(ImageSource source) async { final pickedFile = await ImagePicker().getImage(source: source); @@ -68,16 +69,24 @@ class _AddScreenState extends State { child: IconButton( icon: Icon(Icons.check), onPressed: () async { - if (_formKey.currentState!.validate() && _imageFile != null) { + if (_formKey.currentState!.validate() && _imageFile != null && !_uploading) { + setState(() { + _uploading = true; + }); try { await addNewElementToFirestore(_titleController.text, _descriptionController.text, _imageFile!); Navigator.pop(context); } catch (e) { print(e); // Fehlerbehandlung hier + } finally { + setState(() { + _uploading = false; + }); } } }, + ), ), ],