add suggesstion item wip
This commit is contained in:
parent
d012ac409b
commit
edd2cd1581
@ -44,6 +44,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
String geographicalZone = '';
|
String geographicalZone = '';
|
||||||
String query = '';
|
String query = '';
|
||||||
List<Map<String, dynamic>> suggestions = [];
|
List<Map<String, dynamic>> suggestions = [];
|
||||||
|
List<Map<String, dynamic>> suggestionsItem = [];
|
||||||
TextEditingController inputGeo = TextEditingController();
|
TextEditingController inputGeo = TextEditingController();
|
||||||
TextEditingController startDatepicker = TextEditingController();
|
TextEditingController startDatepicker = TextEditingController();
|
||||||
TextEditingController endDatepicker = TextEditingController();
|
TextEditingController endDatepicker = TextEditingController();
|
||||||
@ -267,6 +268,32 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> searchSuggestionsByItem(String input) async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
|
||||||
|
if (accessToken.isNotEmpty) {
|
||||||
|
final url =
|
||||||
|
'https://api.mapbox.com/geocoding/v5/mapbox.places/${input}.json?access_token=${mapboxAccessToken}&proximity=ip';
|
||||||
|
final response = await http.get(Uri.parse(url));
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final data = json.decode(response.body);
|
||||||
|
setState(() {
|
||||||
|
suggestions = (data['features'] as List)
|
||||||
|
.map((feature) => {
|
||||||
|
'place_name': feature['place_name'],
|
||||||
|
'geometry': feature[
|
||||||
|
'geometry'], // Include geometry for latitude/longitude
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load suggestions');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> fetchPostsByLocation() async {
|
Future<void> fetchPostsByLocation() async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user