I’m customizing the DatePicker
I’m using, and I’m stuck at the widget in the highlighted area. I can’t figure out which widget it is, and therefore, I’m unable to change the text to white color from ThemeData
. How can I achieve this?
I’ve tried several properties, but I couldn’t find the ones that stand out. The code I want to write as an example is as follows:
static final ThemeData lightTheme = ThemeData(
textSelectionTheme: const TextSelectionThemeData(
cursorColor: AppColors.whiteColor,
selectionColor: AppColors.scaffoldColor,
selectionHandleColor: AppColors.activeColor,
),
scaffoldBackgroundColor: AppColors.scaffoldColor,
useMaterial3: true,
appBarTheme: const AppBarTheme(
backgroundColor: AppColors.scaffoldColor,
elevation: 0,
iconTheme: IconThemeData(color: AppColors.whiteColor),
),
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
backgroundColor: AppColors.scaffoldColor,
elevation: 0,
selectedItemColor: AppColors.activeColor,
unselectedItemColor: AppColors.inactiveColor,
type: BottomNavigationBarType.shifting,
),
);
2
Answers
The DatePicker can not be customised directly through ThemeData, but the text inside the DatePicker Header can be customised to an extent.
of the dialog where the DatePicker appears
If these options do not work try using a custom date picker, like Flutter Date Range Picker or Some Calender.
Hope this helps:)
The text color on the mode toggle button is controlled by the
onSurface
color fromColorScheme
. You can modify it for the date picker like this:If you previously used
showDatePicker
, you can move most of its parameters to theDatePickerDialog
constructor.