I am setting up a showTimePicker and I need to set the theme and time format for it. Both are configured in the widget builder but I do not know how to place both configurations to be returned.
This is the code of the TimePicker configuration, I leave commented the lines of the second configuration that I need to add.
final TimeOfDay selectedTime = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
builder: (BuildContext context, Widget child) {
return (
MediaQuery(
data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true),
child: child,
));
/*Theme(
data: ThemeData.dark().copyWith(
colorScheme: ColorScheme.dark(
primary: redColor,
onPrimary: Colors.white,
surface: greyColor,
onSurface: greyVeryLightColor,
),
dialogBackgroundColor: greyLightColor,
),
child: child,
)*/
},
);
Both work separately, but I don't know how to merge the settings.
You can simply wrap the child of MediaQuery widget with Theme widget. Please see the code below :