mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
This reverts commit 973cff40b4
.
This commit is contained in:
parent
e71e8daa20
commit
71a42563db
@ -98,7 +98,7 @@ class _AppBarExampleState extends State<AppBarExample> {
|
|||||||
label: const Text('shadow color'),
|
label: const Text('shadow color'),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
const SizedBox(width: 5),
|
||||||
ElevatedButton(
|
ElevatedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (scrolledUnderElevation == null) {
|
if (scrolledUnderElevation == null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -111,7 +111,8 @@ class _AppBarExampleState extends State<AppBarExample> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
icon: const Icon(Icons.add),
|
||||||
|
label: Text(
|
||||||
'scrolledUnderElevation: ${scrolledUnderElevation ?? 'default'}',
|
'scrolledUnderElevation: ${scrolledUnderElevation ?? 'default'}',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -333,10 +333,10 @@ class ElevatedButton extends ButtonStyleButton {
|
|||||||
/// * hovered - 3
|
/// * hovered - 3
|
||||||
/// * focused or pressed - 1
|
/// * focused or pressed - 1
|
||||||
/// * `padding`
|
/// * `padding`
|
||||||
/// * `textScaleFactor <= 1` - horizontal(24)
|
/// * `textScaleFactor <= 1` - horizontal(16)
|
||||||
/// * `1 < textScaleFactor <= 2` - lerp(horizontal(24), horizontal(12))
|
/// * `1 < textScaleFactor <= 2` - lerp(horizontal(16), horizontal(8))
|
||||||
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(12), horizontal(6))
|
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4))
|
||||||
/// * `3 < textScaleFactor` - horizontal(6)
|
/// * `3 < textScaleFactor` - horizontal(4)
|
||||||
/// * `minimumSize` - Size(64, 40)
|
/// * `minimumSize` - Size(64, 40)
|
||||||
/// * `fixedSize` - null
|
/// * `fixedSize` - null
|
||||||
/// * `maximumSize` - Size.infinite
|
/// * `maximumSize` - Size.infinite
|
||||||
@ -351,10 +351,6 @@ class ElevatedButton extends ButtonStyleButton {
|
|||||||
/// * `enableFeedback` - true
|
/// * `enableFeedback` - true
|
||||||
/// * `alignment` - Alignment.center
|
/// * `alignment` - Alignment.center
|
||||||
/// * `splashFactory` - Theme.splashFactory
|
/// * `splashFactory` - Theme.splashFactory
|
||||||
///
|
|
||||||
/// For the [ElevatedButton.icon] factory, the start (generally the left) value of
|
|
||||||
/// [padding] is reduced from 24 to 16.
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
@ -394,12 +390,10 @@ class ElevatedButton extends ButtonStyleButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
||||||
final bool useMaterial3 = Theme.of(context).useMaterial3;
|
|
||||||
final double padding1x = useMaterial3 ? 24.0 : 16.0;
|
|
||||||
return ButtonStyleButton.scaledPadding(
|
return ButtonStyleButton.scaledPadding(
|
||||||
EdgeInsets.symmetric(horizontal: padding1x),
|
const EdgeInsets.symmetric(horizontal: 16),
|
||||||
EdgeInsets.symmetric(horizontal: padding1x / 2),
|
const EdgeInsets.symmetric(horizontal: 8),
|
||||||
EdgeInsets.symmetric(horizontal: padding1x / 2 / 2),
|
const EdgeInsets.symmetric(horizontal: 4),
|
||||||
MediaQuery.textScaleFactorOf(context),
|
MediaQuery.textScaleFactorOf(context),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -502,13 +496,7 @@ class _ElevatedButtonWithIcon extends ElevatedButton {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
final bool useMaterial3 = Theme.of(context).useMaterial3;
|
final EdgeInsetsGeometry scaledPadding = ButtonStyleButton.scaledPadding(
|
||||||
final EdgeInsetsGeometry scaledPadding = useMaterial3 ? ButtonStyleButton.scaledPadding(
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(16, 0, 24, 0),
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(8, 0, 12, 0),
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(4, 0, 6, 0),
|
|
||||||
MediaQuery.textScaleFactorOf(context),
|
|
||||||
) : ButtonStyleButton.scaledPadding(
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(12, 0, 16, 0),
|
const EdgeInsetsDirectional.fromSTEB(12, 0, 16, 0),
|
||||||
const EdgeInsets.symmetric(horizontal: 8),
|
const EdgeInsets.symmetric(horizontal: 8),
|
||||||
const EdgeInsetsDirectional.fromSTEB(8, 0, 4, 0),
|
const EdgeInsetsDirectional.fromSTEB(8, 0, 4, 0),
|
||||||
|
@ -345,50 +345,6 @@ class FilledButton extends ButtonStyleButton {
|
|||||||
/// shape's [OutlinedBorder.side]. Typically the default value of an
|
/// shape's [OutlinedBorder.side]. Typically the default value of an
|
||||||
/// [OutlinedBorder]'s side is [BorderSide.none], so an outline is not drawn.
|
/// [OutlinedBorder]'s side is [BorderSide.none], so an outline is not drawn.
|
||||||
///
|
///
|
||||||
/// ## Material 3 defaults
|
|
||||||
///
|
|
||||||
/// If [ThemeData.useMaterial3] is set to true the following defaults will
|
|
||||||
/// be used:
|
|
||||||
///
|
|
||||||
/// * `textStyle` - Theme.textTheme.labelLarge
|
|
||||||
/// * `backgroundColor`
|
|
||||||
/// * disabled - Theme.colorScheme.onSurface(0.12)
|
|
||||||
/// * others - Theme.colorScheme.secondaryContainer
|
|
||||||
/// * `foregroundColor`
|
|
||||||
/// * disabled - Theme.colorScheme.onSurface(0.38)
|
|
||||||
/// * others - Theme.colorScheme.onSecondaryContainer
|
|
||||||
/// * `overlayColor`
|
|
||||||
/// * hovered - Theme.colorScheme.onSecondaryContainer(0.08)
|
|
||||||
/// * focused or pressed - Theme.colorScheme.onSecondaryContainer(0.12)
|
|
||||||
/// * `shadowColor` - Theme.colorScheme.shadow
|
|
||||||
/// * `surfaceTintColor` - Colors.transparent
|
|
||||||
/// * `elevation`
|
|
||||||
/// * disabled - 0
|
|
||||||
/// * default - 1
|
|
||||||
/// * hovered - 3
|
|
||||||
/// * focused or pressed - 1
|
|
||||||
/// * `padding`
|
|
||||||
/// * `textScaleFactor <= 1` - horizontal(24)
|
|
||||||
/// * `1 < textScaleFactor <= 2` - lerp(horizontal(24), horizontal(12))
|
|
||||||
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(12), horizontal(6))
|
|
||||||
/// * `3 < textScaleFactor` - horizontal(6)
|
|
||||||
/// * `minimumSize` - Size(64, 40)
|
|
||||||
/// * `fixedSize` - null
|
|
||||||
/// * `maximumSize` - Size.infinite
|
|
||||||
/// * `side` - null
|
|
||||||
/// * `shape` - StadiumBorder()
|
|
||||||
/// * `mouseCursor`
|
|
||||||
/// * disabled - SystemMouseCursors.basic
|
|
||||||
/// * others - SystemMouseCursors.click
|
|
||||||
/// * `visualDensity` - Theme.visualDensity
|
|
||||||
/// * `tapTargetSize` - Theme.materialTapTargetSize
|
|
||||||
/// * `animationDuration` - kThemeChangeDuration
|
|
||||||
/// * `enableFeedback` - true
|
|
||||||
/// * `alignment` - Alignment.center
|
|
||||||
/// * `splashFactory` - Theme.splashFactory
|
|
||||||
///
|
|
||||||
/// For the [FilledButton.icon] factory, the start (generally the left) value of
|
|
||||||
/// [padding] is reduced from 24 to 16.
|
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
switch (_variant) {
|
switch (_variant) {
|
||||||
@ -408,12 +364,10 @@ class FilledButton extends ButtonStyleButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
||||||
final bool useMaterial3 = Theme.of(context).useMaterial3;
|
|
||||||
final double padding1x = useMaterial3 ? 24.0 : 16.0;
|
|
||||||
return ButtonStyleButton.scaledPadding(
|
return ButtonStyleButton.scaledPadding(
|
||||||
EdgeInsets.symmetric(horizontal: padding1x),
|
const EdgeInsets.symmetric(horizontal: 16),
|
||||||
EdgeInsets.symmetric(horizontal: padding1x / 2),
|
const EdgeInsets.symmetric(horizontal: 8),
|
||||||
EdgeInsets.symmetric(horizontal: padding1x / 2 / 2),
|
const EdgeInsets.symmetric(horizontal: 4),
|
||||||
MediaQuery.textScaleFactorOf(context),
|
MediaQuery.textScaleFactorOf(context),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -513,13 +467,7 @@ class _FilledButtonWithIcon extends FilledButton {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
final bool useMaterial3 = Theme.of(context).useMaterial3;
|
final EdgeInsetsGeometry scaledPadding = ButtonStyleButton.scaledPadding(
|
||||||
final EdgeInsetsGeometry scaledPadding = useMaterial3 ? ButtonStyleButton.scaledPadding(
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(16, 0, 24, 0),
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(8, 0, 12, 0),
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(4, 0, 6, 0),
|
|
||||||
MediaQuery.textScaleFactorOf(context),
|
|
||||||
) : ButtonStyleButton.scaledPadding(
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(12, 0, 16, 0),
|
const EdgeInsetsDirectional.fromSTEB(12, 0, 16, 0),
|
||||||
const EdgeInsets.symmetric(horizontal: 8),
|
const EdgeInsets.symmetric(horizontal: 8),
|
||||||
const EdgeInsetsDirectional.fromSTEB(8, 0, 4, 0),
|
const EdgeInsetsDirectional.fromSTEB(8, 0, 4, 0),
|
||||||
|
@ -287,10 +287,10 @@ class OutlinedButton extends ButtonStyleButton {
|
|||||||
/// * `surfaceTintColor` - null
|
/// * `surfaceTintColor` - null
|
||||||
/// * `elevation` - 0
|
/// * `elevation` - 0
|
||||||
/// * `padding`
|
/// * `padding`
|
||||||
/// * `textScaleFactor <= 1` - horizontal(24)
|
/// * `textScaleFactor <= 1` - horizontal(16)
|
||||||
/// * `1 < textScaleFactor <= 2` - lerp(horizontal(24), horizontal(12))
|
/// * `1 < textScaleFactor <= 2` - lerp(horizontal(16), horizontal(8))
|
||||||
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(12), horizontal(6))
|
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4))
|
||||||
/// * `3 < textScaleFactor` - horizontal(6)
|
/// * `3 < textScaleFactor` - horizontal(4)
|
||||||
/// * `minimumSize` - Size(64, 40)
|
/// * `minimumSize` - Size(64, 40)
|
||||||
/// * `fixedSize` - null
|
/// * `fixedSize` - null
|
||||||
/// * `maximumSize` - Size.infinite
|
/// * `maximumSize` - Size.infinite
|
||||||
@ -307,9 +307,6 @@ class OutlinedButton extends ButtonStyleButton {
|
|||||||
/// * `enableFeedback` - true
|
/// * `enableFeedback` - true
|
||||||
/// * `alignment` - Alignment.center
|
/// * `alignment` - Alignment.center
|
||||||
/// * `splashFactory` - Theme.splashFactory
|
/// * `splashFactory` - Theme.splashFactory
|
||||||
///
|
|
||||||
/// For the [OutlinedButton.icon] factory, the start (generally the left) value of
|
|
||||||
/// [padding] is reduced from 24 to 16.
|
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
@ -350,12 +347,10 @@ class OutlinedButton extends ButtonStyleButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
||||||
final bool useMaterial3 = Theme.of(context).useMaterial3;
|
|
||||||
final double padding1x = useMaterial3 ? 24.0 : 16.0;
|
|
||||||
return ButtonStyleButton.scaledPadding(
|
return ButtonStyleButton.scaledPadding(
|
||||||
EdgeInsets.symmetric(horizontal: padding1x),
|
const EdgeInsets.symmetric(horizontal: 16),
|
||||||
EdgeInsets.symmetric(horizontal: padding1x / 2),
|
const EdgeInsets.symmetric(horizontal: 8),
|
||||||
EdgeInsets.symmetric(horizontal: padding1x / 2 / 2),
|
const EdgeInsets.symmetric(horizontal: 4),
|
||||||
MediaQuery.textScaleFactorOf(context),
|
MediaQuery.textScaleFactorOf(context),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -429,23 +424,6 @@ class _OutlinedButtonWithIcon extends OutlinedButton {
|
|||||||
clipBehavior: clipBehavior ?? Clip.none,
|
clipBehavior: clipBehavior ?? Clip.none,
|
||||||
child: _OutlinedButtonWithIconChild(icon: icon, label: label),
|
child: _OutlinedButtonWithIconChild(icon: icon, label: label),
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
|
||||||
final bool useMaterial3 = Theme.of(context).useMaterial3;
|
|
||||||
if (!useMaterial3) {
|
|
||||||
return super.defaultStyleOf(context);
|
|
||||||
}
|
|
||||||
final EdgeInsetsGeometry scaledPadding = ButtonStyleButton.scaledPadding(
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(16, 0, 24, 0),
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(8, 0, 12, 0),
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(4, 0, 6, 0),
|
|
||||||
MediaQuery.textScaleFactorOf(context),
|
|
||||||
);
|
|
||||||
return super.defaultStyleOf(context).copyWith(
|
|
||||||
padding: MaterialStatePropertyAll<EdgeInsetsGeometry>(scaledPadding),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _OutlinedButtonWithIconChild extends StatelessWidget {
|
class _OutlinedButtonWithIconChild extends StatelessWidget {
|
||||||
|
@ -270,7 +270,7 @@ class TextButton extends ButtonStyleButton {
|
|||||||
/// * `shadowColor` - Theme.shadowColor
|
/// * `shadowColor` - Theme.shadowColor
|
||||||
/// * `elevation` - 0
|
/// * `elevation` - 0
|
||||||
/// * `padding`
|
/// * `padding`
|
||||||
/// * `textScaleFactor <= 1` - (horizontal(12), vertical(8))
|
/// * `textScaleFactor <= 1` - all(8)
|
||||||
/// * `1 < textScaleFactor <= 2` - lerp(all(8), horizontal(8))
|
/// * `1 < textScaleFactor <= 2` - lerp(all(8), horizontal(8))
|
||||||
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4))
|
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4))
|
||||||
/// * `3 < textScaleFactor` - horizontal(4)
|
/// * `3 < textScaleFactor` - horizontal(4)
|
||||||
@ -320,7 +320,7 @@ class TextButton extends ButtonStyleButton {
|
|||||||
/// * `surfaceTintColor` - null
|
/// * `surfaceTintColor` - null
|
||||||
/// * `elevation` - 0
|
/// * `elevation` - 0
|
||||||
/// * `padding`
|
/// * `padding`
|
||||||
/// * `textScaleFactor <= 1` - lerp(horizontal(12), horizontal(4))
|
/// * `textScaleFactor <= 1` - all(8)
|
||||||
/// * `1 < textScaleFactor <= 2` - lerp(all(8), horizontal(8))
|
/// * `1 < textScaleFactor <= 2` - lerp(all(8), horizontal(8))
|
||||||
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4))
|
/// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4))
|
||||||
/// * `3 < textScaleFactor` - horizontal(4)
|
/// * `3 < textScaleFactor` - horizontal(4)
|
||||||
@ -338,9 +338,6 @@ class TextButton extends ButtonStyleButton {
|
|||||||
/// * `enableFeedback` - true
|
/// * `enableFeedback` - true
|
||||||
/// * `alignment` - Alignment.center
|
/// * `alignment` - Alignment.center
|
||||||
/// * `splashFactory` - Theme.splashFactory
|
/// * `splashFactory` - Theme.splashFactory
|
||||||
///
|
|
||||||
/// For the [TextButton.icon] factory, the end (generally the right) value of
|
|
||||||
/// [padding] is increased from 12 to 16.
|
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
@ -381,9 +378,8 @@ class TextButton extends ButtonStyleButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
||||||
final bool useMaterial3 = Theme.of(context).useMaterial3;
|
|
||||||
return ButtonStyleButton.scaledPadding(
|
return ButtonStyleButton.scaledPadding(
|
||||||
useMaterial3 ? const EdgeInsets.symmetric(horizontal: 12, vertical: 8) : const EdgeInsets.all(8),
|
const EdgeInsets.all(8),
|
||||||
const EdgeInsets.symmetric(horizontal: 8),
|
const EdgeInsets.symmetric(horizontal: 8),
|
||||||
const EdgeInsets.symmetric(horizontal: 4),
|
const EdgeInsets.symmetric(horizontal: 4),
|
||||||
MediaQuery.textScaleFactorOf(context),
|
MediaQuery.textScaleFactorOf(context),
|
||||||
@ -495,9 +491,8 @@ class _TextButtonWithIcon extends TextButton {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
final bool useMaterial3 = Theme.of(context).useMaterial3;
|
|
||||||
final EdgeInsetsGeometry scaledPadding = ButtonStyleButton.scaledPadding(
|
final EdgeInsetsGeometry scaledPadding = ButtonStyleButton.scaledPadding(
|
||||||
useMaterial3 ? const EdgeInsetsDirectional.fromSTEB(12, 8, 16, 8) : const EdgeInsets.all(8),
|
const EdgeInsets.all(8),
|
||||||
const EdgeInsets.symmetric(horizontal: 4),
|
const EdgeInsets.symmetric(horizontal: 4),
|
||||||
const EdgeInsets.symmetric(horizontal: 4),
|
const EdgeInsets.symmetric(horizontal: 4),
|
||||||
MediaQuery.textScaleFactorOf(context),
|
MediaQuery.textScaleFactorOf(context),
|
||||||
|
@ -1147,59 +1147,6 @@ void main() {
|
|||||||
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('M3 ElevatedButton has correct padding', (WidgetTester tester) async {
|
|
||||||
final Key key = UniqueKey();
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true),
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: ElevatedButton(
|
|
||||||
key: key,
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('ElevatedButton'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final Padding paddingWidget = tester.widget<Padding>(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(key),
|
|
||||||
matching: find.byType(Padding),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(paddingWidget.padding, const EdgeInsets.symmetric(horizontal: 24));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('M3 ElevatedButton.icon has correct padding', (WidgetTester tester) async {
|
|
||||||
final Key key = UniqueKey();
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true),
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: ElevatedButton.icon(
|
|
||||||
key: key,
|
|
||||||
icon: const Icon(Icons.favorite),
|
|
||||||
onPressed: () {},
|
|
||||||
label: const Text('ElevatedButton'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final Padding paddingWidget = tester.widget<Padding>(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(key),
|
|
||||||
matching: find.byType(Padding),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(paddingWidget.padding, const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 24.0, 0.0));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('Elevated buttons animate elevation before color on disable', (WidgetTester tester) async {
|
testWidgets('Elevated buttons animate elevation before color on disable', (WidgetTester tester) async {
|
||||||
// This is a regression test for https://github.com/flutter/flutter/issues/387
|
// This is a regression test for https://github.com/flutter/flutter/issues/387
|
||||||
|
|
||||||
|
@ -1224,59 +1224,6 @@ void main() {
|
|||||||
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('M3 FilledButton has correct padding', (WidgetTester tester) async {
|
|
||||||
final Key key = UniqueKey();
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true),
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: ElevatedButton(
|
|
||||||
key: key,
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('FilledButton'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final Padding paddingWidget = tester.widget<Padding>(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(key),
|
|
||||||
matching: find.byType(Padding),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(paddingWidget.padding, const EdgeInsets.symmetric(horizontal: 24));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('M3 FilledButton.icon has correct padding', (WidgetTester tester) async {
|
|
||||||
final Key key = UniqueKey();
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true),
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: FilledButton.icon(
|
|
||||||
key: key,
|
|
||||||
icon: const Icon(Icons.favorite),
|
|
||||||
onPressed: () {},
|
|
||||||
label: const Text('ElevatedButton'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final Padding paddingWidget = tester.widget<Padding>(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(key),
|
|
||||||
matching: find.byType(Padding),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(paddingWidget.padding, const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 24.0, 0.0));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('By default, FilledButton shape outline is defined by shape.side', (WidgetTester tester) async {
|
testWidgets('By default, FilledButton shape outline is defined by shape.side', (WidgetTester tester) async {
|
||||||
const Color borderColor = Color(0xff4caf50);
|
const Color borderColor = Color(0xff4caf50);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
|
@ -1388,59 +1388,6 @@ void main() {
|
|||||||
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('M3 OutlinedButton has correct padding', (WidgetTester tester) async {
|
|
||||||
final Key key = UniqueKey();
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true),
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: OutlinedButton(
|
|
||||||
key: key,
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('OutlinedButton'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final Padding paddingWidget = tester.widget<Padding>(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(key),
|
|
||||||
matching: find.byType(Padding),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(paddingWidget.padding, const EdgeInsets.symmetric(horizontal: 24));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('M3 OutlinedButton.icon has correct padding', (WidgetTester tester) async {
|
|
||||||
final Key key = UniqueKey();
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true),
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: OutlinedButton.icon(
|
|
||||||
key: key,
|
|
||||||
icon: const Icon(Icons.favorite),
|
|
||||||
onPressed: () {},
|
|
||||||
label: const Text('OutlinedButton'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final Padding paddingWidget = tester.widget<Padding>(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(key),
|
|
||||||
matching: find.byType(Padding),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(paddingWidget.padding, const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 24.0, 0.0));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('Fixed size OutlinedButtons', (WidgetTester tester) async {
|
testWidgets('Fixed size OutlinedButtons', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
|
@ -1195,59 +1195,6 @@ void main() {
|
|||||||
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('M3 TextButton has correct default padding', (WidgetTester tester) async {
|
|
||||||
final Key key = UniqueKey();
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true),
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: TextButton(
|
|
||||||
key: key,
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('TextButton'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final Padding paddingWidget = tester.widget<Padding>(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(key),
|
|
||||||
matching: find.byType(Padding),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(paddingWidget.padding, const EdgeInsets.symmetric(horizontal: 12,vertical: 8));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('M3 TextButton.icon has correct default padding', (WidgetTester tester) async {
|
|
||||||
final Key key = UniqueKey();
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true),
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: TextButton.icon(
|
|
||||||
key: key,
|
|
||||||
onPressed: () {},
|
|
||||||
icon: const Icon(Icons.add),
|
|
||||||
label: const Text('TextButton'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final Padding paddingWidget = tester.widget<Padding>(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(key),
|
|
||||||
matching: find.byType(Padding),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(paddingWidget.padding, const EdgeInsetsDirectional.fromSTEB(12, 8, 16, 8));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('Fixed size TextButtons', (WidgetTester tester) async {
|
testWidgets('Fixed size TextButtons', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
|
@ -589,17 +589,15 @@ void main() {
|
|||||||
case MaterialType.material2:
|
case MaterialType.material2:
|
||||||
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(154, 155)));
|
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(154, 155)));
|
||||||
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(281, 165)));
|
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(281, 165)));
|
||||||
expect(tester.getBottomRight(find.text(okString)).dx, 644);
|
|
||||||
expect(tester.getBottomLeft(find.text(okString)).dx, 616);
|
|
||||||
expect(tester.getBottomRight(find.text(cancelString)).dx, 582);
|
|
||||||
break;
|
break;
|
||||||
case MaterialType.material3:
|
case MaterialType.material3:
|
||||||
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(138, 129)));
|
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(138, 129)));
|
||||||
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(292.0, 143.0)));
|
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(292.0, 143.0)));
|
||||||
expect(tester.getBottomLeft(find.text(okString)).dx, 616);
|
|
||||||
expect(tester.getBottomRight(find.text(cancelString)).dx, 578);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
expect(tester.getBottomRight(find.text(okString)).dx, 644);
|
||||||
|
expect(tester.getBottomLeft(find.text(okString)).dx, 616);
|
||||||
|
expect(tester.getBottomRight(find.text(cancelString)).dx, 582);
|
||||||
|
|
||||||
await tester.tap(find.text(okString));
|
await tester.tap(find.text(okString));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
@ -612,18 +610,15 @@ void main() {
|
|||||||
case MaterialType.material2:
|
case MaterialType.material2:
|
||||||
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(519, 155)));
|
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(519, 155)));
|
||||||
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(646, 165)));
|
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(646, 165)));
|
||||||
expect(tester.getBottomLeft(find.text(okString)).dx, 156);
|
|
||||||
expect(tester.getBottomRight(find.text(okString)).dx, 184);
|
|
||||||
expect(tester.getBottomLeft(find.text(cancelString)).dx, 218);
|
|
||||||
break;
|
break;
|
||||||
case MaterialType.material3:
|
case MaterialType.material3:
|
||||||
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(508, 129)));
|
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(508, 129)));
|
||||||
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(662, 143)));
|
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(662, 143)));
|
||||||
expect(tester.getBottomLeft(find.text(okString)).dx, 156);
|
|
||||||
expect(tester.getBottomRight(find.text(okString)).dx, 184);
|
|
||||||
expect(tester.getBottomLeft(find.text(cancelString)).dx, 222);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
expect(tester.getBottomLeft(find.text(okString)).dx, 156);
|
||||||
|
expect(tester.getBottomRight(find.text(okString)).dx, 184);
|
||||||
|
expect(tester.getBottomLeft(find.text(cancelString)).dx, 218);
|
||||||
|
|
||||||
await tester.tap(find.text(okString));
|
await tester.tap(find.text(okString));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
Loading…
Reference in New Issue
Block a user