fix datepicker
This commit is contained in:
parent
792ce0227e
commit
045209575e
@ -65,10 +65,14 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
|
||||
onTapFunctionDatePicker(
|
||||
{required BuildContext context, required String position}) async {
|
||||
String date = "start_date";
|
||||
if (position == "end") {
|
||||
date = "end_date";
|
||||
}
|
||||
DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
firstDate: DateTime.parse(widget.events["date"]),
|
||||
initialDate: DateTime.parse(widget.events["date"]),
|
||||
firstDate: DateTime.parse(widget.events[date]),
|
||||
initialDate: DateTime.parse(widget.events[date]),
|
||||
lastDate: DateTime(2104));
|
||||
if (pickedDate == null) return;
|
||||
if (position == "start") {
|
||||
@ -81,10 +85,14 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
|
||||
onTapFunctionTimePicker(
|
||||
{required BuildContext context, required String position}) async {
|
||||
String date = "start_date";
|
||||
if (position == "end") {
|
||||
date = "end_date";
|
||||
}
|
||||
TimeOfDay? pickedDate = await showTimePicker(
|
||||
context: context,
|
||||
initialTime:
|
||||
TimeOfDay.fromDateTime(DateTime.parse(widget.events["date"])));
|
||||
TimeOfDay.fromDateTime(DateTime.parse(widget.events[date])));
|
||||
if (pickedDate == null) return;
|
||||
if (position == "start") {
|
||||
startTimepicker.text = pickedDate.format(context);
|
||||
@ -273,6 +281,11 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
super.initState();
|
||||
}
|
||||
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
String? _validateField(String? value) {
|
||||
return value!.isEmpty ? 'Champ requis' : null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -282,7 +295,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
backgroundColor: Colors.blue,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
@ -299,8 +314,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
Padding(
|
||||
//padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0),
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: inputName,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Nom',
|
||||
@ -311,8 +327,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: inputAddress,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Adresse',
|
||||
@ -323,8 +340,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: inputZipCode,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Code postal',
|
||||
@ -335,8 +353,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: inputCity,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Ville',
|
||||
@ -347,8 +366,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: inputCountry,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Pays',
|
||||
@ -359,9 +379,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: startDatepicker,
|
||||
readOnly: true,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Date de debut',
|
||||
@ -373,9 +394,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: startTimepicker,
|
||||
readOnly: true,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Heure de debut',
|
||||
@ -387,9 +409,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: endDatepicker,
|
||||
readOnly: true,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Date de fin',
|
||||
@ -401,9 +424,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: TextField(
|
||||
child: TextFormField(
|
||||
controller: endTimepicker,
|
||||
readOnly: true,
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Heure de fin',
|
||||
@ -460,10 +484,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
),
|
||||
color: Colors.blue,
|
||||
),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
margin:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 5.0),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10.0, vertical: 5.0),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 10.0,
|
||||
vertical: 5.0),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
@ -471,7 +498,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
children: [
|
||||
InkWell(
|
||||
child: Text(
|
||||
'#$tag',
|
||||
'$tag',
|
||||
style: const TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
@ -552,10 +579,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
),
|
||||
color: Colors.blue,
|
||||
),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
margin:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 5.0),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10.0, vertical: 5.0),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 10.0,
|
||||
vertical: 5.0),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
@ -616,10 +646,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
height: 50,
|
||||
width: 250,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue, borderRadius: BorderRadius.circular(20)),
|
||||
color: Colors.blue,
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_updateEvent(context);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
'Ajouter',
|
||||
@ -630,6 +663,6 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user