add input date
This commit is contained in:
parent
4d3533eb8a
commit
cdae84090f
@ -46,6 +46,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
String query = '';
|
||||
List<Map<String, dynamic>> suggestions = [];
|
||||
TextEditingController inputGeo = TextEditingController();
|
||||
TextEditingController Datepicker = TextEditingController();
|
||||
|
||||
// Fetching events from API
|
||||
static Future<List<Events>> getPosts() async {
|
||||
@ -118,6 +119,8 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
super.initState();
|
||||
// Initialize data fetch when the page loads
|
||||
_getCurrentLocation();
|
||||
|
||||
Datepicker.text = DateFormat("dd-MM-yyyy").format(new DateTime.now());
|
||||
}
|
||||
|
||||
// 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() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@ -388,6 +416,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
body: Column(
|
||||
children: [
|
||||
_buildGeographicalZoneSearchField(),
|
||||
_BuildDateField(),
|
||||
Expanded(
|
||||
child: FutureBuilder<List<Events>>(
|
||||
future: postsFuture,
|
||||
|
Loading…
x
Reference in New Issue
Block a user