Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize a TimePicker widget in Flutter

enter image description here

How can you change the Purple selection color, Purple border color, time text color and Hour and Minute color from the input time picker widget, can't seem to find the properties in TimePickerThemeData

like image 639
Hector Avatar asked Oct 19 '25 02:10

Hector


1 Answers

You are able to use states on your theme too! Controlling the styles when making some action (like selected or focused actions).

Here an example:

final theme = ThemeData.light().copyWith(
  timePickerTheme: TimePickerThemeData(
    backgroundColor: Colors.green.shade200,
    hourMinuteColor: MaterialStateColor.resolveWith((states) =>
        states.contains(MaterialState.selected)
            ? Colors.blue.withOpacity(0.2)
            : Colors.orange),
    hourMinuteTextColor: MaterialStateColor.resolveWith((states) =>
        states.contains(MaterialState.selected)
            ? Colors.pink
            : Colors.deepPurple),
    dialHandColor: Colors.pink.shade800,
    dialBackgroundColor: Colors.purple.withOpacity(0.5),
    dialTextColor: MaterialStateColor.resolveWith((states) =>
        states.contains(MaterialState.selected)
            ? Colors.green
            : Colors.black),
    entryModeIconColor: Colors.yellow
    ),
    textTheme: TextTheme(
      overline: TextStyle(
        color: Colors.red,
      ),
    ),
    textButtonTheme: TextButtonThemeData(
        style: ButtonStyle(
      backgroundColor: MaterialStateColor.resolveWith((states) => Colors.black),
      foregroundColor: MaterialStateColor.resolveWith((states) => Colors.green),
      overlayColor: MaterialStateColor.resolveWith((states) => Colors.pink),
    )));

enter image description here enter image description here enter image description here

like image 137
Nyorok Avatar answered Oct 22 '25 04:10

Nyorok



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!