mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Replace SizedBox spacing with spacing parameter in Row usages (#168688)
This PR refactors Flutter widgets that use SizedBox for spacing between children in Row into using the spacing parameter instead. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
This commit is contained in:
parent
c685293fc4
commit
a2c2d2c8de
@ -631,9 +631,9 @@ class _Tile extends StatelessWidget {
|
||||
heightFactor: 1,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 8,
|
||||
children: <Widget>[
|
||||
icon,
|
||||
const SizedBox(width: 8),
|
||||
// Flexible lets the overflow property of
|
||||
// label to work and IntrinsicWidth gives label a
|
||||
// reasonable width preventing extra space before it.
|
||||
|
||||
@ -539,7 +539,6 @@ class _ElevatedButtonWithIconChild extends StatelessWidget {
|
||||
buttonStyle?.textStyle?.resolve(const <MaterialState>{})?.fontSize ?? 14.0;
|
||||
final double scale =
|
||||
clampDouble(MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0, 1.0, 2.0) - 1.0;
|
||||
final double gap = lerpDouble(8, 4, scale)!;
|
||||
final ElevatedButtonThemeData elevatedButtonTheme = ElevatedButtonTheme.of(context);
|
||||
final IconAlignment effectiveIconAlignment =
|
||||
iconAlignment ??
|
||||
@ -548,10 +547,11 @@ class _ElevatedButtonWithIconChild extends StatelessWidget {
|
||||
IconAlignment.start;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: lerpDouble(8, 4, scale)!,
|
||||
children:
|
||||
effectiveIconAlignment == IconAlignment.start
|
||||
? <Widget>[icon, SizedBox(width: gap), Flexible(child: label)]
|
||||
: <Widget>[Flexible(child: label), SizedBox(width: gap), icon],
|
||||
? <Widget>[icon, Flexible(child: label)]
|
||||
: <Widget>[Flexible(child: label), icon],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -588,9 +588,7 @@ class _FilledButtonWithIconChild extends StatelessWidget {
|
||||
buttonStyle?.textStyle?.resolve(const <MaterialState>{})?.fontSize ?? 14.0;
|
||||
final double scale =
|
||||
clampDouble(MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0, 1.0, 2.0) - 1.0;
|
||||
// Adjust the gap based on the text scale factor. Start at 8, and lerp
|
||||
// to 4 based on how large the text is.
|
||||
final double gap = lerpDouble(8, 4, scale)!;
|
||||
|
||||
final FilledButtonThemeData filledButtonTheme = FilledButtonTheme.of(context);
|
||||
final IconAlignment effectiveIconAlignment =
|
||||
iconAlignment ??
|
||||
@ -599,10 +597,11 @@ class _FilledButtonWithIconChild extends StatelessWidget {
|
||||
IconAlignment.start;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: lerpDouble(8, 4, scale)!,
|
||||
children:
|
||||
effectiveIconAlignment == IconAlignment.start
|
||||
? <Widget>[icon, SizedBox(width: gap), Flexible(child: label)]
|
||||
: <Widget>[Flexible(child: label), SizedBox(width: gap), icon],
|
||||
? <Widget>[icon, Flexible(child: label)]
|
||||
: <Widget>[Flexible(child: label), icon],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ class _OutlinedButtonWithIconChild extends StatelessWidget {
|
||||
buttonStyle?.textStyle?.resolve(const <MaterialState>{})?.fontSize ?? 14.0;
|
||||
final double scale =
|
||||
clampDouble(MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0, 1.0, 2.0) - 1.0;
|
||||
final double gap = lerpDouble(8, 4, scale)!;
|
||||
|
||||
final OutlinedButtonThemeData outlinedButtonTheme = OutlinedButtonTheme.of(context);
|
||||
final IconAlignment effectiveIconAlignment =
|
||||
iconAlignment ??
|
||||
@ -496,10 +496,11 @@ class _OutlinedButtonWithIconChild extends StatelessWidget {
|
||||
IconAlignment.start;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: lerpDouble(8, 4, scale)!,
|
||||
children:
|
||||
effectiveIconAlignment == IconAlignment.start
|
||||
? <Widget>[icon, SizedBox(width: gap), Flexible(child: label)]
|
||||
: <Widget>[Flexible(child: label), SizedBox(width: gap), icon],
|
||||
? <Widget>[icon, Flexible(child: label)]
|
||||
: <Widget>[Flexible(child: label), icon],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,7 +516,6 @@ class _TextButtonWithIconChild extends StatelessWidget {
|
||||
buttonStyle?.textStyle?.resolve(const <MaterialState>{})?.fontSize ?? 14.0;
|
||||
final double scale =
|
||||
clampDouble(MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0, 1.0, 2.0) - 1.0;
|
||||
final double gap = lerpDouble(8, 4, scale)!;
|
||||
final TextButtonThemeData textButtonTheme = TextButtonTheme.of(context);
|
||||
final IconAlignment effectiveIconAlignment =
|
||||
iconAlignment ??
|
||||
@ -525,10 +524,11 @@ class _TextButtonWithIconChild extends StatelessWidget {
|
||||
IconAlignment.start;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: lerpDouble(8, 4, scale)!,
|
||||
children:
|
||||
effectiveIconAlignment == IconAlignment.start
|
||||
? <Widget>[icon, SizedBox(width: gap), Flexible(child: label)]
|
||||
: <Widget>[Flexible(child: label), SizedBox(width: gap), icon],
|
||||
? <Widget>[icon, Flexible(child: label)]
|
||||
: <Widget>[Flexible(child: label), icon],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user