removed objects for which no files are present in the location key from the list of objects returned by getLocationSearchData
This commit is contained in:
parent
611c252a07
commit
7c379bcdab
|
@ -1,4 +1,3 @@
|
|||
import 'dart:developer';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
|
@ -908,9 +907,9 @@ class UserService {
|
|||
List<Map<String, dynamic>> locationSearchResult = [];
|
||||
|
||||
for (var locationAndBbox in matchedLocationNamesAndBboxs) {
|
||||
log(locationAndBbox.toString());
|
||||
locationSearchResult
|
||||
.add({'place': locationAndBbox['place'], "matchingFiles": []});
|
||||
bool foundFileInLocation = false;
|
||||
for (File file in allFiles) {
|
||||
if (_isValidLocation(file.location)) {
|
||||
if (file.location.latitude >
|
||||
|
@ -922,14 +921,16 @@ class UserService {
|
|||
file.location.longitude <
|
||||
locationAndBbox['bbox']['northEastCoordinates'].longitude) {
|
||||
locationSearchResult.last["matchingFiles"].add(file);
|
||||
foundFileInLocation = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
log('locationSearchResult-----');
|
||||
log(locationSearchResult.length.toString());
|
||||
if (!foundFileInLocation) {
|
||||
locationSearchResult.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
log('out of loactionAndBBox loop');
|
||||
//[{'place':'india', 'matchedFiles':[f1,f2,f3...]},{'place':....}, ..}]
|
||||
return locationSearchResult;
|
||||
} on DioError catch (e) {
|
||||
_logger.info(e);
|
||||
|
|
|
@ -23,6 +23,7 @@ class _SearchIconWidgetState extends State<SearchIconWidget> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
debugPrint('showSearchWidget-----------');
|
||||
showSearchWidget = false;
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,7 @@ class _SearchIconWidgetState extends State<SearchIconWidget> {
|
|||
await FilesDB.instance.getFilesOnFileNameSearch(value);
|
||||
matchedFilesWithLocation =
|
||||
await UserService.instance.getLocationSearchData(value);
|
||||
log("sss----------------------");
|
||||
log(matchedFilesWithLocation.toString());
|
||||
_searchQuery.value = value;
|
||||
},
|
||||
autofocus: true,
|
||||
|
|
Loading…
Reference in a new issue