update
This commit is contained in:
@ -13,11 +13,12 @@ List<GeoJsonFeature> searchResults = <GeoJsonFeature>[].obs;
|
||||
@override
|
||||
void onInit() {
|
||||
IndexController indexController = Get.find<IndexController>();
|
||||
for(int i=0; i<= indexController.locations[0].collection.length - 1; i++){
|
||||
GeoJsonFeature p = indexController.locations[0].collection[i];
|
||||
searchResults.add(p);
|
||||
|
||||
}
|
||||
if(indexController.locations.isNotEmpty){
|
||||
for(int i=0; i<= indexController.locations[0].collection.length - 1; i++){
|
||||
GeoJsonFeature p = indexController.locations[0].collection[i];
|
||||
searchResults.add(p);
|
||||
}
|
||||
}
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/pages/search/search_controller.dart';
|
||||
@ -36,21 +38,24 @@ class SearchPage extends StatelessWidget {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,)),
|
||||
title: const CupertinoSearchTextField(),
|
||||
|
||||
),
|
||||
body:
|
||||
//Obx(() =>
|
||||
ListView.builder(
|
||||
itemCount: searchController.searchResults.length,
|
||||
itemBuilder: (context, index){
|
||||
return ListTile(
|
||||
title: Text(searchController.searchResults[index].properties!["location_name"]),
|
||||
subtitle: Text(searchController.searchResults[index].properties!["category"]),
|
||||
leading: getImage(index),
|
||||
onTap: (){
|
||||
title: TypeAheadField(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
autofocus: true,
|
||||
),
|
||||
suggestionsCallback: (pattern) async{
|
||||
return searchController.searchResults.where((GeoJsonFeature element) => element.properties!["location_name"].toString().contains(pattern));
|
||||
//return await
|
||||
},
|
||||
itemBuilder: (context, GeoJsonFeature suggestion){
|
||||
return ListTile(
|
||||
title: Text(suggestion.properties!["location_name"]),
|
||||
subtitle: suggestion.properties!["category"] != null ? Text(suggestion.properties!["category"]) : Text(""),
|
||||
//leading: getImage(index),
|
||||
);
|
||||
},
|
||||
onSuggestionSelected: (GeoJsonFeature suggestion){
|
||||
indexController.currentFeature.clear();
|
||||
indexController.currentFeature.add(searchController.searchResults[index]);
|
||||
indexController.currentFeature.add(suggestion);
|
||||
Get.back();
|
||||
showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
@ -58,11 +63,35 @@ class SearchPage extends StatelessWidget {
|
||||
//builder: (context) => BottomSheetWidget(),
|
||||
builder:((context) => BottomSheetNew())
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
),
|
||||
//title: const CupertinoSearchTextField(),
|
||||
|
||||
),
|
||||
//)
|
||||
//body:
|
||||
// Obx(() =>
|
||||
// ListView.builder(
|
||||
// itemCount: searchController.searchResults.length,
|
||||
// itemBuilder: (context, index){
|
||||
// return ListTile(
|
||||
// title: searchController.searchResults[index].properties!["location_name"] != null ? Text(searchController.searchResults[index].properties!["location_name"]) : Text(""),
|
||||
// subtitle: searchController.searchResults[index].properties!["category"] != null ? Text(searchController.searchResults[index].properties!["category"]) : Text(""),
|
||||
// leading: getImage(index),
|
||||
// onTap: (){
|
||||
// indexController.currentFeature.clear();
|
||||
// indexController.currentFeature.add(searchController.searchResults[index]);
|
||||
// Get.back();
|
||||
// showModalBottomSheet(
|
||||
// isScrollControlled: true,
|
||||
// context: context,
|
||||
// //builder: (context) => BottomSheetWidget(),
|
||||
// builder:((context) => BottomSheetNew())
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// )
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user