Remove textScaleFactor references from flutter/flutter (#142271)

These should the the last remaining `MediaQueryData.textScaleFactor` and `TextScaler.textScaleFactor` references.
This commit is contained in:
LongCatIsLooong
2024-01-26 11:12:24 -08:00
committed by GitHub
parent 5b44596c5f
commit 505845c5ac
16 changed files with 73 additions and 67 deletions

View File

@@ -33,6 +33,10 @@ class ProductCard extends StatelessWidget {
fit: BoxFit.cover,
);
// The fontSize to use for computing the heuristic UI scaling factor.
const double defaultFontSize = 14.0;
final double containerScaingFactor = MediaQuery.textScalerOf(context).scale(defaultFontSize) / defaultFontSize;
return ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget? child, AppStateModel model) {
return GestureDetector(
@@ -52,8 +56,7 @@ class ProductCard extends StatelessWidget {
child: imageWidget,
),
SizedBox(
// ignore: deprecated_member_use, https://github.com/flutter/flutter/issues/128825
height: kTextBoxHeight * MediaQuery.textScalerOf(context).textScaleFactor,
height: kTextBoxHeight * containerScaingFactor,
width: 121.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,

View File

@@ -178,8 +178,9 @@ class _DemoItem extends StatelessWidget {
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final bool isDark = theme.brightness == Brightness.dark;
// ignore: deprecated_member_use, https://github.com/flutter/flutter/issues/128825
final double textScaleFactor = MediaQuery.textScalerOf(context).textScaleFactor;
// The fontSize to use for computing the heuristic UI scaling factor.
const double defaultFontSize = 14.0;
final double containerScaingFactor = MediaQuery.textScalerOf(context).scale(defaultFontSize) / defaultFontSize;
return RawMaterialButton(
splashColor: theme.primaryColor.withOpacity(0.12),
highlightColor: Colors.transparent,
@@ -187,7 +188,7 @@ class _DemoItem extends StatelessWidget {
_launchDemo(context);
},
child: Container(
constraints: BoxConstraints(minHeight: _kDemoItemHeight * textScaleFactor),
constraints: BoxConstraints(minHeight: _kDemoItemHeight * containerScaingFactor),
child: Row(
children: <Widget>[
Container(