Safe guard against null locations

This commit is contained in:
Vishnu Mohandas 2020-06-07 02:42:49 +05:30
parent bbf289971b
commit 2f3aa8da6a
2 changed files with 8 additions and 2 deletions

View file

@ -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];

View file

@ -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<LocationSearchResultsPage> {
ViewPort viewPort = args['viewPort'];
final result = List<Photo>();
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) {