Search code examples
fluttermaterial-design

How to change the primary color of the Flutter Material 3 DatePicker?


I am using showDatePicker() to display a Datepicker in my Flutter App.

How can I change the purple color?

Here is my Theme so far:

DatePickerThemeData(
  backgroundColor: Color.fromARGB(255, 38, 41, 48),
  surfaceTintColor: Colors.transparent,
  headerForegroundColor: Colors.white,
                  )

enter image description here


Solution

  • try this :

    DatePickerThemeData(
                backgroundColor: Color.fromARGB(255, 38, 41, 48),
                surfaceTintColor: Colors.transparent,
                headerForegroundColor: Colors.white,
    
                //u need to match the text color also
                dayBackgroundColor: MaterialStateProperty.resolveWith((states) {
                  if (states.contains(MaterialState.selected)) {
                    return Colors.green;
                  }
                  return Colors.black;
                }),)