Dev, examples/api, etc updated for Material 3 by default (#129683)

Updated tests in dev, examples/api, and tests/widgets to ensure that
they continue to pass when the default for `ThemeData.useMaterial3` is
changed to true.

This is the final set of changes required for
https://github.com/flutter/flutter/issues/127064.
This commit is contained in:
Hans Muller
2023-06-28 09:41:58 -07:00
committed by GitHub
parent 32fe4d7f0a
commit 0d4b5ae122
29 changed files with 231 additions and 199 deletions

View File

@@ -79,30 +79,29 @@ class _BodyState extends State<Body> with WidgetsBindingObserver {
return Center(
child: SizedBox(
width: 300,
child: IntrinsicHeight(
child: Column(
children: <Widget>[
RadioListTile<bool>(
title: const Text('Do Not Allow Exit'),
groupValue: _shouldExit,
value: false,
onChanged: _radioChanged,
),
RadioListTile<bool>(
title: const Text('Allow Exit'),
groupValue: _shouldExit,
value: true,
onChanged: _radioChanged,
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: _quit,
child: const Text('Quit'),
),
const SizedBox(height: 30),
Text(lastResponse),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RadioListTile<bool>(
title: const Text('Do Not Allow Exit'),
groupValue: _shouldExit,
value: false,
onChanged: _radioChanged,
),
RadioListTile<bool>(
title: const Text('Allow Exit'),
groupValue: _shouldExit,
value: true,
onChanged: _radioChanged,
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: _quit,
child: const Text('Quit'),
),
const SizedBox(height: 30),
Text(lastResponse),
],
),
),
);

View File

@@ -18,8 +18,9 @@ class HeroApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HeroExample(),
return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const HeroExample(),
);
}
}

View File

@@ -13,8 +13,9 @@ class AnimatedSlideApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: AnimatedSlideExample(),
return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const AnimatedSlideExample(),
);
}
}

View File

@@ -22,7 +22,7 @@ void main() {
// Jump 25% into the transition (total length = 300ms)
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
expect(heroSize.width.roundToDouble(), 171.0);
expect(heroSize.width.roundToDouble(), 170.0);
expect(heroSize.height.roundToDouble(), 73.0);
// Jump to 50% into the transition.
@@ -61,7 +61,7 @@ void main() {
// Jump to 75% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
expect(heroSize.width.roundToDouble(), 171.0);
expect(heroSize.width.roundToDouble(), 170.0);
expect(heroSize.height.roundToDouble(), 73.0);
// Jump to 100% into the transition.

View File

@@ -23,7 +23,7 @@ void main() {
logoOffset = tester.getCenter(find.byType(FlutterLogo));
expect(logoOffset.dx.roundToDouble(), 376.0);
expect(logoOffset.dy.roundToDouble(), 140.0);
expect(logoOffset.dy.roundToDouble(), 137.0);
// Test X axis slider.
final Offset x = tester.getCenter(find.text('X'));
@@ -32,6 +32,6 @@ void main() {
logoOffset = tester.getCenter(find.byType(FlutterLogo));
expect(logoOffset.dx.roundToDouble(), 178.0);
expect(logoOffset.dy.roundToDouble(), 140.0);
expect(logoOffset.dy.roundToDouble(), 137.0);
});
}