Przeglądaj źródła

Fix crash in imageEdit for remote files

Neeraj Gupta 4 lat temu
rodzic
commit
a0b3010348
2 zmienionych plików z 6 dodań i 2 usunięć
  1. 5 0
      lib/models/file.dart
  2. 1 2
      lib/ui/image_editor_page.dart

+ 5 - 0
lib/models/file.dart

@@ -133,6 +133,11 @@ class File {
     return localID == null && uploadedFileID != null;
   }
 
+  bool hasLocation() {
+    return location != null &&
+        (location.longitude != 0 || location.latitude != 0);
+  }
+
   @override
   String toString() {
     return '''File(generatedId: $generatedID, uploadedFileId: $uploadedFileID, 

+ 1 - 2
lib/ui/image_editor_page.dart

@@ -319,8 +319,7 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
       newFile.creationTime = widget.originalFile.creationTime;
       newFile.collectionID = widget.originalFile.collectionID;
       newFile.location = widget.originalFile.location;
-      if (newFile.location == null ||
-          (newFile.location.latitude == 0 && newFile.location.longitude == 0)) {
+      if (!newFile.hasLocation() && widget.originalFile.localID != null) {
         final latLong =
             await (await widget.originalFile.getAsset()).latlngAsync();
         newFile.location = Location(latLong.latitude, latLong.longitude);