@@ -149,8 +149,9 @@ const double _kMaxRegularTextScaleFactor = 1.4;
149149// Accessibility mode on iOS is determined by the text scale factor that the
150150// user has selected.
151151bool _isInAccessibilityMode (BuildContext context) {
152- final double ? factor = MediaQuery .maybeTextScalerOf (context)? .textScaleFactor;
153- return factor != null && factor > _kMaxRegularTextScaleFactor;
152+ const double defaultFontSize = 14.0 ;
153+ final double ? scaledFontSize = MediaQuery .maybeTextScalerOf (context)? .scale (defaultFontSize);
154+ return scaledFontSize != null && scaledFontSize > defaultFontSize * _kMaxRegularTextScaleFactor;
154155}
155156
156157/// An iOS-style alert dialog.
@@ -264,7 +265,8 @@ class _CupertinoAlertDialogState extends State<CupertinoAlertDialog> {
264265 widget.actionScrollController ?? (_backupActionScrollController ?? = ScrollController ());
265266
266267 Widget _buildContent (BuildContext context) {
267- final double textScaleFactor = MediaQuery .textScalerOf (context).textScaleFactor;
268+ const double defaultFontSize = 14.0 ;
269+ final double effectiveTextScaleFactor = MediaQuery .textScalerOf (context).scale (defaultFontSize) / defaultFontSize;
268270
269271 final List <Widget > children = < Widget > [
270272 if (widget.title != null || widget.content != null )
@@ -278,12 +280,12 @@ class _CupertinoAlertDialogState extends State<CupertinoAlertDialog> {
278280 left: _kDialogEdgePadding,
279281 right: _kDialogEdgePadding,
280282 bottom: widget.content == null ? _kDialogEdgePadding : 1.0 ,
281- top: _kDialogEdgePadding * textScaleFactor ,
283+ top: _kDialogEdgePadding * effectiveTextScaleFactor ,
282284 ),
283285 messagePadding: EdgeInsets .only (
284286 left: _kDialogEdgePadding,
285287 right: _kDialogEdgePadding,
286- bottom: _kDialogEdgePadding * textScaleFactor ,
288+ bottom: _kDialogEdgePadding * effectiveTextScaleFactor ,
287289 top: widget.title == null ? _kDialogEdgePadding : 1.0 ,
288290 ),
289291 titleTextStyle: _kCupertinoDialogTitleStyle.copyWith (
@@ -1653,10 +1655,6 @@ class CupertinoDialogAction extends StatelessWidget {
16531655 /// value.
16541656 bool get enabled => onPressed != null ;
16551657
1656- double _calculatePadding (BuildContext context) {
1657- return 8.0 * MediaQuery .textScalerOf (context).textScaleFactor;
1658- }
1659-
16601658 // Dialog action content shrinks to fit, up to a certain point, and if it still
16611659 // cannot fit at the minimum size, the text content is ellipsized.
16621660 //
@@ -1665,6 +1663,7 @@ class CupertinoDialogAction extends StatelessWidget {
16651663 required BuildContext context,
16661664 required TextStyle textStyle,
16671665 required Widget content,
1666+ required double padding,
16681667 }) {
16691668 final bool isInAccessibilityMode = _isInAccessibilityMode (context);
16701669 final double dialogWidth = isInAccessibilityMode
@@ -1675,7 +1674,6 @@ class CupertinoDialogAction extends StatelessWidget {
16751674 // buttons. This ratio information is used to automatically scale down action
16761675 // button text to fit the available space.
16771676 final double fontSizeRatio = MediaQuery .textScalerOf (context).scale (textStyle.fontSize! ) / _kDialogMinButtonFontSize;
1678- final double padding = _calculatePadding (context);
16791677
16801678 return IntrinsicHeight (
16811679 child: SizedBox (
@@ -1724,8 +1722,7 @@ class CupertinoDialogAction extends StatelessWidget {
17241722 isDestructiveAction ? CupertinoColors .systemRed : CupertinoTheme .of (context).primaryColor,
17251723 context,
17261724 ),
1727- );
1728- style = style.merge (textStyle);
1725+ ).merge (textStyle);
17291726
17301727 if (isDefaultAction) {
17311728 style = style.copyWith (fontWeight: FontWeight .w600);
@@ -1734,7 +1731,10 @@ class CupertinoDialogAction extends StatelessWidget {
17341731 if (! enabled) {
17351732 style = style.copyWith (color: style.color! .withOpacity (0.5 ));
17361733 }
1737-
1734+ final double fontSize = style.fontSize ?? kDefaultFontSize;
1735+ final double fontSizeToScale = fontSize == 0.0 ? kDefaultFontSize : fontSize;
1736+ final double effectiveTextScale = MediaQuery .textScalerOf (context).scale (fontSizeToScale) / fontSizeToScale;
1737+ final double padding = 8.0 * effectiveTextScale;
17381738 // Apply a sizing policy to the action button's content based on whether or
17391739 // not the device is in accessibility mode.
17401740 // TODO(mattcarroll): The following logic is not entirely correct. It is also
@@ -1750,6 +1750,7 @@ class CupertinoDialogAction extends StatelessWidget {
17501750 context: context,
17511751 textStyle: style,
17521752 content: child,
1753+ padding: padding,
17531754 );
17541755
17551756 return MouseRegion (
@@ -1764,7 +1765,7 @@ class CupertinoDialogAction extends StatelessWidget {
17641765 ),
17651766 child: Container (
17661767 alignment: Alignment .center,
1767- padding: EdgeInsets .all (_calculatePadding (context) ),
1768+ padding: EdgeInsets .all (padding ),
17681769 child: sizedContent,
17691770 ),
17701771 ),
0 commit comments