How to change font size for CupertinoDatePicker in

2020-04-18 09:08发布

问题:

I need to change the font size of CupertinoDatePicker so it looks more like native one. The font is small compared to ios datepicker. For the height wrapping in a Container with height of MediaQuery.of(context).copyWith().size.height / 3 makes the height to be similar to native one.

回答1:

Another way to do this, is to wrap the CupertinoDatePicker in CupertinoTheme.

CupertinoTheme(
    data: CupertinoThemeData(
        textTheme: CupertinoTextThemeData(
            dateTimePickerTextStyle: TextStyle(
                fontSize: 16,
            ),
        ),
     ),
     child: CupertinoDatePicker(
          ...


回答2:

Finally got it, works as expected.

DefaultTextStyle.merge(
      style: TextStyle(fontSize: 20),
      child: CupertinoDatePicker(....)
)