@@ -477,21 +477,28 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
477477 final DatePickerThemeData defaults = DatePickerTheme .defaults (context);
478478 final TextTheme textTheme = theme.textTheme;
479479
480- // Constrain the textScaleFactor to the largest supported value to prevent
481- // layout issues.
482- final double textScaleFactor = math.min (MediaQuery .textScaleFactorOf (context), 1.3 );
480+ // There's no M3 spec for a landscape layout input (not calendar)
481+ // date picker. To ensure that the date displayed in the input
482+ // date picker's header fits in landscape mode, we override the M3
483+ // default here.
484+ TextStyle ? headlineStyle;
485+ if (useMaterial3) {
486+ headlineStyle = datePickerTheme.headerHeadlineStyle ?? defaults.headerHeadlineStyle;
487+ switch (_entryMode.value) {
488+ case DatePickerEntryMode .input:
489+ case DatePickerEntryMode .inputOnly:
490+ if (orientation == Orientation .landscape) {
491+ headlineStyle = textTheme.headlineSmall;
492+ }
493+ case DatePickerEntryMode .calendar:
494+ case DatePickerEntryMode .calendarOnly:
495+ // M3 default is OK.
496+ }
497+ } else {
498+ headlineStyle = orientation == Orientation .landscape ? textTheme.headlineSmall : textTheme.headlineMedium;
499+ }
483500 final Color ? headerForegroundColor = datePickerTheme.headerForegroundColor ?? defaults.headerForegroundColor;
484- final TextStyle ? headlineStyle = useMaterial3
485- ? (datePickerTheme.headerHeadlineStyle ?? defaults.headerHeadlineStyle)? .copyWith (
486- color: headerForegroundColor,
487- )
488- // Material2 has support for landscape and the current M3 spec doesn't
489- // address this layout, so handling it separately here.
490- : (orientation == Orientation .landscape
491- ? textTheme.headlineSmall? .copyWith (color: headerForegroundColor)
492- : textTheme.headlineMedium? .copyWith (color: headerForegroundColor));
493-
494- final String dateText = localizations.formatMediumDate (_selectedDate.value);
501+ headlineStyle = headlineStyle? .copyWith (color: headerForegroundColor);
495502
496503 final Widget actions = Container (
497504 alignment: AlignmentDirectional .centerEnd,
@@ -599,13 +606,16 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
599606 ? localizations.datePickerHelpText
600607 : localizations.datePickerHelpText.toUpperCase ()
601608 ),
602- titleText: dateText ,
609+ titleText: localizations. formatMediumDate (_selectedDate.value) ,
603610 titleStyle: headlineStyle,
604611 orientation: orientation,
605612 isShort: orientation == Orientation .landscape,
606613 entryModeButton: entryModeButton,
607614 );
608615
616+ // Constrain the textScaleFactor to the largest supported value to prevent
617+ // layout issues.
618+ final double textScaleFactor = math.min (MediaQuery .textScaleFactorOf (context), 1.3 );
609619 final Size dialogSize = _dialogSize (context) * textScaleFactor;
610620 final DialogTheme dialogTheme = theme.dialogTheme;
611621 return Dialog (
@@ -2660,10 +2670,16 @@ class _InputDateRangePickerDialog extends StatelessWidget {
26602670 final DatePickerThemeData datePickerTheme = DatePickerTheme .of (context);
26612671 final DatePickerThemeData defaults = DatePickerTheme .defaults (context);
26622672
2673+ // There's no M3 spec for a landscape layout input (not calendar)
2674+ // date range picker. To ensure that the date range displayed in the
2675+ // input date range picker's header fits in landscape mode, we override
2676+ // the M3 default here.
2677+ TextStyle ? headlineStyle = (orientation == Orientation .portrait)
2678+ ? datePickerTheme.headerHeadlineStyle ?? defaults.headerHeadlineStyle
2679+ : Theme .of (context).textTheme.headlineSmall;
2680+
26632681 final Color ? headerForegroundColor = datePickerTheme.headerForegroundColor ?? defaults.headerForegroundColor;
2664- final TextStyle ? headlineStyle = (datePickerTheme.headerHeadlineStyle ?? defaults.headerHeadlineStyle)? .copyWith (
2665- color: headerForegroundColor,
2666- );
2682+ headlineStyle = headlineStyle? .copyWith (color: headerForegroundColor);
26672683
26682684 final String dateText = _formatDateRange (context, selectedStartDate, selectedEndDate, currentDate! );
26692685 final String semanticDateText = selectedStartDate != null && selectedEndDate != null
0 commit comments