@@ -477,21 +477,28 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
477
477
final DatePickerThemeData defaults = DatePickerTheme .defaults (context);
478
478
final TextTheme textTheme = theme.textTheme;
479
479
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
+ }
483
500
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);
495
502
496
503
final Widget actions = Container (
497
504
alignment: AlignmentDirectional .centerEnd,
@@ -599,13 +606,16 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
599
606
? localizations.datePickerHelpText
600
607
: localizations.datePickerHelpText.toUpperCase ()
601
608
),
602
- titleText: dateText ,
609
+ titleText: localizations. formatMediumDate (_selectedDate.value) ,
603
610
titleStyle: headlineStyle,
604
611
orientation: orientation,
605
612
isShort: orientation == Orientation .landscape,
606
613
entryModeButton: entryModeButton,
607
614
);
608
615
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 );
609
619
final Size dialogSize = _dialogSize (context) * textScaleFactor;
610
620
final DialogTheme dialogTheme = theme.dialogTheme;
611
621
return Dialog (
@@ -2660,10 +2670,16 @@ class _InputDateRangePickerDialog extends StatelessWidget {
2660
2670
final DatePickerThemeData datePickerTheme = DatePickerTheme .of (context);
2661
2671
final DatePickerThemeData defaults = DatePickerTheme .defaults (context);
2662
2672
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
+
2663
2681
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);
2667
2683
2668
2684
final String dateText = _formatDateRange (context, selectedStartDate, selectedEndDate, currentDate! );
2669
2685
final String semanticDateText = selectedStartDate != null && selectedEndDate != null
0 commit comments