i updated but dropdownbutton not updating right now . can u say why ?
Expanded(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: softColor)),
child: DropdownButton<CustomerModel>(
dropdownColor: Colors.white,
borderRadius: BorderRadius.circular(5),
underline: SizedBox(),
hint: CustomTextBody(
text: 'Select Customer'),
isExpanded: true,
icon: Icon(
Icons.arrow_drop_down,
color: softColor,
),
value:
selectedCustomer ?? allCustomers[0],
items: List.generate(
allCustomers.length,
(index) =>
DropdownMenuItem<CustomerModel>(
value: allCustomers[index],
child: CustomTextBody(
text:
allCustomers[index].companyName,
),
),
),
onChanged: (CustomerModel? value) {
setState(
() {
selectedCustomer = value!;
},
);
},
),
),
),
I was able to figure it out by using a plugin (flutter_datetime_picker 1.3.4). I altered it a bit to fit my needs.
TextFormField(
decoration: InputDecoration(
labelText: 'Course Name',
contentPadding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.blueAccent, width: 1.0),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.blueAccent, width: 2.0),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
),
),
new SizedBox(
height: 20.0,
),
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(32.0),
side: BorderSide(color: Colors.blueAccent)),
onPressed: () {
DatePicker.showDatePicker(context,
theme: DatePickerTheme(
containerHeight: 210.0,
),
showTitleActions: true,
minTime: DateTime(1940, 1, 1),
maxTime: DateTime.now(), onConfirm: (date) {
print('confirm $date');
_date = '${date.month} / ${date.day} / ${date.year}';
//_date = '${date.year} - ${date.month} - ${date.day}';
setState(() {});
}, currentTime: DateTime.now(), locale: LocaleType.en);
},
child: Container(
alignment: Alignment.center,
height: 50.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
Container(
child: Row(
children: <Widget>[
Text(
" $_date",
style: TextStyle(
color: Colors.black, fontSize: 16.0),
),
],
),
)
],
),
Text(
" Change",
style:
TextStyle(color: Colors.blueAccent, fontSize: 16.0),
),
],
),
),
color: Colors.white,
),
SizedBox(
height: 20.0,
),
],
),
),
),
);
}
}