diff --git a/lib/db/photo_db.dart b/lib/db/photo_db.dart index f2fb93e76..269b44aba 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 6b181c476..37b6ad068 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) {