diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 0acdcc48d0..9681370a52 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -687,7 +687,7 @@ class _DatePickerDialogState extends State with RestorationMix final Size portraitDialogSize = useMaterial3 ? _inputPortraitDialogSizeM3 : _inputPortraitDialogSizeM2; // Make sure the portrait dialog can fit the contents comfortably when // resized from the landscape dialog. - final bool isFullyPortrait = constraints.maxHeight >= portraitDialogSize.height; + final bool isFullyPortrait = constraints.maxHeight >= math.min(dialogSize.height, portraitDialogSize.height); switch (orientation) { case Orientation.portrait: @@ -2874,6 +2874,8 @@ class _InputDateRangePickerDialog extends StatelessWidget { ), ); + final double textScaleFactor = MediaQuery.textScalerOf(context).clamp(maxScaleFactor: _kMaxTextScaleFactor).textScaleFactor; + final Size dialogSize = (useMaterial3 ? _inputPortraitDialogSizeM3 : _inputPortraitDialogSizeM2) * textScaleFactor; switch (orientation) { case Orientation.portrait: return LayoutBuilder( @@ -2881,7 +2883,7 @@ class _InputDateRangePickerDialog extends StatelessWidget { final Size portraitDialogSize = useMaterial3 ? _inputPortraitDialogSizeM3 : _inputPortraitDialogSizeM2; // Make sure the portrait dialog can fit the contents comfortably when // resized from the landscape dialog. - final bool isFullyPortrait = constraints.maxHeight >= portraitDialogSize.height; + final bool isFullyPortrait = constraints.maxHeight >= math.min(dialogSize.height, portraitDialogSize.height); return Column( mainAxisSize: MainAxisSize.min, diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index 10c2a74f60..5965054e30 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -2,6 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// This file is run as part of a reduced test set in CI on Mac and Windows +// machines. +@Tags(['reduced-test-set']) +library; + import 'dart:ui'; import 'package:flutter/foundation.dart'; @@ -69,20 +74,24 @@ void main() { TextDirection textDirection = TextDirection.ltr, bool useMaterial3 = false, ThemeData? theme, + TextScaler textScaler = TextScaler.noScaling, }) async { late BuildContext buttonContext; await tester.pumpWidget(MaterialApp( theme: theme ?? ThemeData(useMaterial3: useMaterial3), - home: Material( - child: Builder( - builder: (BuildContext context) { - return ElevatedButton( - onPressed: () { - buttonContext = context; - }, - child: const Text('Go'), - ); - }, + home: MediaQuery( + data: MediaQueryData(textScaler: textScaler), + child: Material( + child: Builder( + builder: (BuildContext context) { + return ElevatedButton( + onPressed: () { + buttonContext = context; + }, + child: const Text('Go'), + ); + }, + ), ), ), )); @@ -1472,7 +1481,7 @@ void main() { }); // This is a regression test for https://github.com/flutter/flutter/issues/131989. - testWidgetsWithLeakTracking('Dialog contents do not overflow when resized from landscape to portrait', + testWidgetsWithLeakTracking('Dialog contents do not overflow when resized during orientation change', (WidgetTester tester) async { addTearDown(tester.view.reset); // Initial window size is wide for landscape mode. @@ -1486,6 +1495,36 @@ void main() { expect(tester.takeException(), null); }); }); + + // This is a regression test for https://github.com/flutter/flutter/issues/139120. + testWidgetsWithLeakTracking('Dialog contents are visible - textScaler 0.88, 1.0, 2.0', + (WidgetTester tester) async { + addTearDown(tester.view.reset); + tester.view.physicalSize = const Size(400, 800); + tester.view.devicePixelRatio = 1.0; + final List scales = [0.88, 1.0, 2.0]; + + for (final double scale in scales) { + await tester.pumpWidget( + MaterialApp( + home: MediaQuery( + data: MediaQueryData(textScaler: TextScaler.linear(scale)), + child: Material( + child: DatePickerDialog( + firstDate: DateTime(2001), + lastDate: DateTime(2031, DateTime.december, 31), + initialDate: DateTime(2016, DateTime.january, 15), + initialEntryMode: DatePickerEntryMode.input, + ), + ), + ), + ), + ); + await tester.pumpAndSettle(); + + await expectLater(find.byType(Dialog), matchesGoldenFile('date_picker.dialog.contents.visible.$scale.png')); + } + }); }); group('Semantics', () {