error handling on image upload
This commit is contained in:
parent
a41e5c19c3
commit
93c0e883d3
|
@ -73,6 +73,7 @@ class CreatePost extends HookWidget {
|
|||
);
|
||||
|
||||
uploadPicture() async {
|
||||
try {
|
||||
final pic = await imagePicker.getImage(source: ImageSource.gallery);
|
||||
// pic is null when the picker was cancelled
|
||||
if (pic != null) {
|
||||
|
@ -84,6 +85,12 @@ class CreatePost extends HookWidget {
|
|||
pictrsDeleteToken.value = upload.files[0];
|
||||
urlController.text =
|
||||
pathToPictrs(selectedInstance.value, upload.files[0].file);
|
||||
}
|
||||
// ignore: avoid_catches_without_on_clauses
|
||||
} catch (e) {
|
||||
scaffoldKey.currentState
|
||||
.showSnackBar(SnackBar(content: Text('Failed to upload image')));
|
||||
} finally {
|
||||
imageUploadLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue