fixed search bug

This commit is contained in:
Mohamed Nouffer
2023-07-18 11:28:35 +05:30
parent c756c4a5be
commit 7a9adf8f06
2 changed files with 48 additions and 30 deletions

View File

@ -35,40 +35,58 @@ class SearchPage extends StatelessWidget {
backgroundColor: Colors.white,
leading: IconButton(
onPressed:(){
Navigator.pop(context);
Get.back();
},
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,)),
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(suggestion);
Get.back();
showModalBottomSheet(
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder:((context) => BottomSheetNew())
);
},
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,)
),
centerTitle: true,
//title: const CupertinoSearchTextField(),
),
//body:
body: SingleChildScrollView(
child: TypeAheadField(
textFieldConfiguration: TextFieldConfiguration(
autofocus: true,
style: DefaultTextStyle.of(context).style.copyWith(
fontStyle: FontStyle.normal,
fontSize: 15.0,
),
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: "検索",
prefixIcon: Icon(Icons.search),
suffixIcon: IconButton(
icon: Icon(Icons.clear),
onPressed: () {
// clear the text field
},
),
),
),
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(suggestion);
Get.back();
showModalBottomSheet(
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder:((context) => BottomSheetNew())
);
},
),
),
// Obx(() =>
// ListView.builder(
// itemCount: searchController.searchResults.length,