add cache for position
This commit is contained in:
parent
f693ffa6b8
commit
c6a0c2f4f1
@ -172,6 +172,9 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
// Reverse geocode: Get city and country from latitude and longitude using Mapbox Search API
|
||||
if (position != null) {
|
||||
_getCityAndCountry(position!.latitude, position!.longitude);
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.setDouble("city_lat", position!.latitude);
|
||||
prefs.setDouble("city_long", position!.longitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -335,6 +338,9 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
context: context, firstDate: dateEvent, lastDate: DateTime(2104));
|
||||
if (pickedDate == null) return;
|
||||
Datepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||
if (inputGeo.text.isEmpty) {
|
||||
_fetchInitialData();
|
||||
} else {}
|
||||
}
|
||||
|
||||
Padding _BuildDateField() {
|
||||
@ -345,7 +351,16 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
controller: Datepicker,
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(), hintText: 'Recherche par date'),
|
||||
border: OutlineInputBorder(),
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
Datepicker.text = '';
|
||||
});
|
||||
},
|
||||
),
|
||||
hintText: 'Recherche par date'),
|
||||
onTap: () => onTapFunctionDatePicker(context: context)),
|
||||
);
|
||||
}
|
||||
@ -405,6 +420,10 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
});
|
||||
|
||||
await fetchPostsByLocation(latitude, longitude);
|
||||
SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
prefs.setDouble("city_lat", latitude);
|
||||
prefs.setDouble("city_long", longitude);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user