add input date
This commit is contained in:
parent
4d3533eb8a
commit
cdae84090f
@ -46,6 +46,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
String query = '';
|
String query = '';
|
||||||
List<Map<String, dynamic>> suggestions = [];
|
List<Map<String, dynamic>> suggestions = [];
|
||||||
TextEditingController inputGeo = TextEditingController();
|
TextEditingController inputGeo = TextEditingController();
|
||||||
|
TextEditingController Datepicker = TextEditingController();
|
||||||
|
|
||||||
// Fetching events from API
|
// Fetching events from API
|
||||||
static Future<List<Events>> getPosts() async {
|
static Future<List<Events>> getPosts() async {
|
||||||
@ -118,6 +119,8 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
// Initialize data fetch when the page loads
|
// Initialize data fetch when the page loads
|
||||||
_getCurrentLocation();
|
_getCurrentLocation();
|
||||||
|
|
||||||
|
Datepicker.text = DateFormat("dd-MM-yyyy").format(new DateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the device's current location
|
// Get the device's current location
|
||||||
@ -296,6 +299,31 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onTapFunctionDatePicker({required BuildContext context}) async {
|
||||||
|
DateTime dateEvent = DateTime.now();
|
||||||
|
|
||||||
|
DateTime? pickedDate = await showDatePicker(
|
||||||
|
context: context,
|
||||||
|
firstDate: dateEvent,
|
||||||
|
initialDate: dateEvent,
|
||||||
|
lastDate: DateTime(2104));
|
||||||
|
if (pickedDate == null) return;
|
||||||
|
Datepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
Padding _BuildDateField() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: Datepicker,
|
||||||
|
readOnly: true,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: OutlineInputBorder(), hintText: 'Recherche par date'),
|
||||||
|
onTap: () => onTapFunctionDatePicker(context: context)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Padding _buildGeographicalZoneSearchField() {
|
Padding _buildGeographicalZoneSearchField() {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@ -388,6 +416,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
_buildGeographicalZoneSearchField(),
|
_buildGeographicalZoneSearchField(),
|
||||||
|
_BuildDateField(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: FutureBuilder<List<Events>>(
|
child: FutureBuilder<List<Events>>(
|
||||||
future: postsFuture,
|
future: postsFuture,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user