Skip to content

Commit

Permalink
removes Material (#96899)
Browse files Browse the repository at this point in the history
  • Loading branch information
werainkhatri authored Feb 8, 2022
1 parent a6504ea commit 26d4e92
Show file tree
Hide file tree
Showing 8 changed files with 410 additions and 528 deletions.
174 changes: 78 additions & 96 deletions packages/flutter/test/material/elevated_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -419,20 +419,18 @@ void main() {
final GlobalKey childKey = GlobalKey();
bool hovering = false;
await tester.pumpWidget(
Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: SizedBox(
width: 100,
height: 100,
child: ElevatedButton(
autofocus: true,
onPressed: () {},
onLongPress: () {},
onHover: (bool value) { hovering = value; },
focusNode: focusNode,
child: SizedBox(key: childKey),
),
Directionality(
textDirection: TextDirection.ltr,
child: SizedBox(
width: 100,
height: 100,
child: ElevatedButton(
autofocus: true,
onPressed: () {},
onLongPress: () {},
onHover: (bool value) { hovering = value; },
focusNode: focusNode,
child: SizedBox(key: childKey),
),
),
),
Expand All @@ -447,18 +445,16 @@ void main() {
expect(hovering, isTrue);

await tester.pumpWidget(
Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: SizedBox(
width: 100,
height: 100,
child: ElevatedButton(
focusNode: focusNode,
onHover: (bool value) { hovering = value; },
onPressed: null,
child: SizedBox(key: childKey),
),
Directionality(
textDirection: TextDirection.ltr,
child: SizedBox(
width: 100,
height: 100,
child: ElevatedButton(
focusNode: focusNode,
onHover: (bool value) { hovering = value; },
onPressed: null,
child: SizedBox(key: childKey),
),
),
),
Expand All @@ -473,21 +469,19 @@ void main() {
late bool hover;

Widget buildFrame({ required bool enabled }) {
return Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
width: 100,
height: 100,
child: ElevatedButton(
onPressed: enabled ? () { } : null,
onHover: (bool value) {
onHoverCount += 1;
hover = value;
},
child: const Text('ElevatedButton'),
),
return Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
width: 100,
height: 100,
child: ElevatedButton(
onPressed: enabled ? () { } : null,
onHover: (bool value) {
onHoverCount += 1;
hover = value;
},
child: const Text('ElevatedButton'),
),
),
),
Expand Down Expand Up @@ -537,15 +531,13 @@ void main() {
final FocusNode node = FocusNode(debugLabel: 'ElevatedButton Focus');
bool gotFocus = false;
await tester.pumpWidget(
Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: ElevatedButton(
focusNode: node,
onFocusChange: (bool focused) => gotFocus = focused,
onPressed: () { },
child: const SizedBox(),
),
Directionality(
textDirection: TextDirection.ltr,
child: ElevatedButton(
focusNode: node,
onFocusChange: (bool focused) => gotFocus = focused,
onPressed: () { },
child: const SizedBox(),
),
),
);
Expand All @@ -568,15 +560,13 @@ void main() {
final FocusNode node = FocusNode(debugLabel: 'ElevatedButton Focus');
bool gotFocus = false;
await tester.pumpWidget(
Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: ElevatedButton(
focusNode: node,
onFocusChange: (bool focused) => gotFocus = focused,
onPressed: null,
child: const SizedBox(),
),
Directionality(
textDirection: TextDirection.ltr,
child: ElevatedButton(
focusNode: node,
onFocusChange: (bool focused) => gotFocus = focused,
onPressed: null,
child: const SizedBox(),
),
),
);
Expand Down Expand Up @@ -681,18 +671,16 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: Center(
child: ElevatedButton(
style: ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the semantics tree's rect and transform
// match the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)),
),
onPressed: () { },
child: const Text('ABC'),
child: Center(
child: ElevatedButton(
style: ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the semantics tree's rect and transform
// match the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)),
),
onPressed: () { },
child: const Text('ABC'),
),
),
),
Expand Down Expand Up @@ -736,14 +724,12 @@ void main() {
data: ThemeData(materialTapTargetSize: tapTargetSize),
child: Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: Center(
child: ElevatedButton(
key: key,
style: style,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () { },
),
child: Center(
child: ElevatedButton(
key: key,
style: style,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () { },
),
),
),
Expand All @@ -763,11 +749,9 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: ElevatedButton(
onPressed: () { /* to make sure the button is enabled */ },
child: const Text('button'),
),
child: ElevatedButton(
onPressed: () { /* to make sure the button is enabled */ },
child: const Text('button'),
),
),
);
Expand Down Expand Up @@ -855,19 +839,17 @@ void main() {
// horizontal padding is applied correctly later on
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: Center(
child: ElevatedButton.icon(
key: buttonKey,
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.fromLTRB(16, 5, 10, 12)),
),
onPressed: () {},
icon: const Icon(Icons.add),
label: const Text(
'Hello',
key: labelKey,
),
child: Center(
child: ElevatedButton.icon(
key: buttonKey,
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.fromLTRB(16, 5, 10, 12)),
),
onPressed: () {},
icon: const Icon(Icons.add),
label: const Text(
'Hello',
key: labelKey,
),
),
),
Expand Down
84 changes: 35 additions & 49 deletions packages/flutter/test/material/flat_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,9 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: FlatButton(
child: Container(),
onPressed: () { /* to make sure the button is enabled */ },
),
child: FlatButton(
child: Container(),
onPressed: () { /* to make sure the button is enabled */ },
),
),
);
Expand Down Expand Up @@ -536,12 +534,10 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: Center(
child: FlatButton(
onPressed: () { },
child: const Text('ABC'),
),
child: Center(
child: FlatButton(
onPressed: () { },
child: const Text('ABC'),
),
),
),
Expand Down Expand Up @@ -576,14 +572,12 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: MediaQuery(
data: const MediaQueryData(),
child: Center(
child: FlatButton(
onPressed: () { },
child: const Text('ABC'),
),
child: MediaQuery(
data: const MediaQueryData(),
child: Center(
child: FlatButton(
onPressed: () { },
child: const Text('ABC'),
),
),
),
Expand All @@ -597,14 +591,12 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: MediaQuery(
data: const MediaQueryData(textScaleFactor: 1.3),
child: Center(
child: FlatButton(
onPressed: () { },
child: const Text('ABC'),
),
child: MediaQuery(
data: const MediaQueryData(textScaleFactor: 1.3),
child: Center(
child: FlatButton(
onPressed: () { },
child: const Text('ABC'),
),
),
),
Expand All @@ -621,14 +613,12 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: MediaQuery(
data: const MediaQueryData(textScaleFactor: 3.0),
child: Center(
child: FlatButton(
onPressed: () { },
child: const Text('ABC'),
),
child: MediaQuery(
data: const MediaQueryData(textScaleFactor: 3.0),
child: Center(
child: FlatButton(
onPressed: () { },
child: const Text('ABC'),
),
),
),
Expand All @@ -650,13 +640,11 @@ void main() {
data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded),
child: Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: Center(
child: FlatButton(
key: key1,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () { },
),
child: Center(
child: FlatButton(
key: key1,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () { },
),
),
),
Expand All @@ -671,13 +659,11 @@ void main() {
data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: Center(
child: FlatButton(
key: key2,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () { },
),
child: Center(
child: FlatButton(
key: key2,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () { },
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,9 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: FloatingActionButton(
focusNode: focusNode,
onPressed: () { /* to make sure the button is enabled */ },
),
child: FloatingActionButton(
focusNode: focusNode,
onPressed: () { /* to make sure the button is enabled */ },
),
),
);
Expand Down
Loading

0 comments on commit 26d4e92

Please sign in to comment.