diff --git a/lib/db/photo_db.dart b/lib/db/photo_db.dart index f2fb93e76c5e4687dfb91e9367451ded59f3ffce..269b44abab1ccc9b820c7219012a7b64c4e621d7 100644 --- a/lib/db/photo_db.dart +++ b/lib/db/photo_db.dart @@ -324,7 +324,9 @@ class PhotoDB { photo.uploadedFileId = row[columnUploadedFileId]; photo.title = row[columnTitle]; photo.deviceFolder = row[columnDeviceFolder]; - photo.location = Location(row[columnLatitude], row[columnLongitude]); + if (row[columnLatitude] != null && row[columnLongitude] != null) { + photo.location = Location(row[columnLatitude], row[columnLongitude]); + } photo.remoteFolderId = row[columnRemoteFolderId]; photo.remotePath = row[columnRemotePath]; photo.thumbnailPath = row[columnThumbnailPath]; diff --git a/lib/ui/location_search_results_page.dart b/lib/ui/location_search_results_page.dart index 6b181c476f6065906cd62fe5e8ed596e0e0b2cdc..37b6ad068d1f07c63d0237d9e5cc7a19725d6a2f 100644 --- a/lib/ui/location_search_results_page.dart +++ b/lib/ui/location_search_results_page.dart @@ -13,6 +13,9 @@ class ViewPort { final Location southWest; ViewPort(this.northEast, this.southWest); + + @override + String toString() => 'ViewPort(northEast: $northEast, southWest: $southWest)'; } class LocationSearchResultsPage extends StatefulWidget { @@ -74,7 +77,8 @@ class _LocationSearchResultsPageState extends State { ViewPort viewPort = args['viewPort']; final result = List(); for (final photo in photos) { - if (viewPort.northEast.latitude > photo.location.latitude && + if (photo.location != null && + viewPort.northEast.latitude > photo.location.latitude && viewPort.southWest.latitude < photo.location.latitude && viewPort.northEast.longitude > photo.location.longitude && viewPort.southWest.longitude < photo.location.longitude) {