From 2625d322dd1b43b6c0ca3aa12d6147a30942bf1f Mon Sep 17 00:00:00 2001 From: Vande Perre Nathan Date: Fri, 18 Sep 2020 15:49:18 +0200 Subject: [PATCH] fix(camera) : fixed error on camera cancel --- CHANGELOG.md | 1 + lib/pages/items_page.dart | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cdedefb..bdd1ce9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -144,6 +144,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Analytics : Added new analytics - Wishlist color : wishslist color is now fixed on a new wishlist - Item image : items with old images now have an icon +- Camera : fixed error on camera cancel ### Security diff --git a/lib/pages/items_page.dart b/lib/pages/items_page.dart index a89e0e8c..aab13e64 100644 --- a/lib/pages/items_page.dart +++ b/lib/pages/items_page.dart @@ -465,18 +465,25 @@ class EditItemPageState extends State { } Future pickImage() async { - await _imageService - .pickCamera(30, 720, 720) - .then((image) => pickedImage = File(image.path)); + String path; - setState(() { - _itemImage = Image( - image: FileImage(pickedImage), - fit: BoxFit.cover, - ); + await _imageService.pickCamera(30, 720, 720).then((image) { + if (image != null && image.path != null) { + path = image.path; + } }); - imageType = "Picked"; + if (path != null) { + pickedImage = File(path); + setState(() { + _itemImage = Image( + image: FileImage(pickedImage), + fit: BoxFit.cover, + ); + }); + + imageType = "Picked"; + } } int getTypeIndex() {