Fix ColorScheme example and tests (#150018)

## Description

This fixes the `ColorScheme` example to actually work.  The test had wrapped the app in an additional `MaterialApp`, which allowed the tests to work, but the real problem was using a `context` that was outside the `MaterialApp` to open the bottom sheet, which caused an exception when you actually try to run it interactively.

This fixes the example and the test.

## Tests
 - Fixed the test to not artificially add a second `MaterialApp`.
This commit is contained in:
Greg Spencer
2024-06-11 22:07:23 -07:00
committed by GitHub
parent 14df7be3f9
commit 966d2b9223
2 changed files with 65 additions and 37 deletions

View File

@@ -9,8 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('ColorScheme Smoke Test', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(home: example.ColorSchemeExample()
),
const example.ColorSchemeExample(),
);
expect(find.text('tonalSpot (Default)'), findsOneWidget);
@@ -19,7 +18,7 @@ void main() {
testWidgets('Change color seed', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(home: example.ColorSchemeExample()),
const example.ColorSchemeExample(),
);
ColoredBox coloredBox() {
@@ -31,8 +30,9 @@ void main() {
);
}
expect(coloredBox().color, const Color(0xff65558f));
await tester.tap(find.byIcon(Icons.settings));
await tester.tap(find.byType(example.SettingsButton));
await tester.pumpAndSettle();
expect(find.text('Settings'), findsOneWidget);
await tester.tap(find.byType(IconButton).at(6));
await tester.pumpAndSettle();