I'm trying to change the color of the date picker but still have the blue color in there. I tried a lot but I can't find the code that changes the blue colors (see below).
The text: Enter Date, the underline, and Cancel & OK button should all be teal as color.

This is my code so far. Thanks for the support!
TextEditingController _dateController = new TextEditingController();
DateTime selectedDate = DateTime.now();
var myFormat = DateFormat('d-MM-yyyy');
Future<void> _selectDate(BuildContext context) async {
final DateTime picked = await showDatePicker(
context: context,
initialDate: selectedDate,
firstDate: DateTime(1930),
lastDate: DateTime(2022),
builder: (BuildContext context, Widget child) {
return Theme(
data: ThemeData.light().copyWith(
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.teal,
primaryColorDark: Colors.teal,
accentColor: Colors.teal,
),
dialogBackgroundColor:Colors.white,
),
child: child,
);
},
);
if (picked != null && picked != selectedDate)
setState(() {
selectedDate = picked;
});
}
Try this instead
TextEditingController _dateController = new TextEditingController();
DateTime selectedDate = DateTime.now();
var myFormat = DateFormat('d-MM-yyyy');
Future<void> _selectDate(BuildContext context) async {
final DateTime picked = await showDatePicker(
context: context,
initialDate: selectedDate,
firstDate: DateTime(1930),
lastDate: DateTime(2022),
builder: (BuildContext context, Widget child) {
return Theme(
data: ThemeData.light().copyWith(
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.teal,
primaryColorDark: Colors.teal,
accentColor: Colors.teal,
),
dialogBackgroundColor:Colors.white,
),
child: child,
);
},
);
if (picked != null && picked != selectedDate)
setState(() {
selectedDate = picked;
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With