Skip to content
Merged
1 change: 0 additions & 1 deletion dev/bots/check_tests_cross_imports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ class TestsCrossImportChecker {
'packages/flutter/test/widgets/system_context_menu_test.dart',
'packages/flutter/test/widgets/scrollable_fling_test.dart',
'packages/flutter/test/widgets/debug_test.dart',
'packages/flutter/test/widgets/banner_test.dart',
'packages/flutter/test/widgets/transformed_scrollable_test.dart',
'packages/flutter/test/widgets/run_app_async_test.dart',
'packages/flutter/test/widgets/scrollable_in_overlay_test.dart',
Expand Down
8 changes: 5 additions & 3 deletions packages/flutter/test/widgets/banner_test.dart

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merely "moving" the file does not address this issue.

The checked mode banner widget is also used for CupertinoApp, so the proper fix is to replace MaterialApp and friends in this file with their flutter/widgets counterpart. This is blocked on #180456

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did manage to fix this without moving the file in #181274

Maybe we should prefer that PR?

@kazbeksultanov kazbeksultanov Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was my bad; it seems like I misunderstood this task.

I agree that TestWidgetsApp is really needed. But I don't see it yet on the master.

I expected that TestWidgetsApp is required because, there will be a lot of defaults values to be passed.
But for this exact case I was able to use WidgetsApp with default parameters to simulate Material.
Now, I think we can create private _TestWidgetApp in each file where it's required by tests, and adjust it for that use case only without generating one universal TestWidgetsApp for all cases.

What do you think? Is it ok?
@justinmc @navaronbracke

@navaronbracke navaronbracke Jan 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a TestWidgetsApp that will be introduced soon, but that PR is not yet merged. If it works for banner_test.dart by providing WidgetsApp with some defaults, then LGTM.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this case seems like it's working fine.
@navaronbracke @justinmc can you take a look?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

import 'widgets_app_tester.dart';

class TestCanvas implements Canvas {
final List<Invocation> invocations = <Invocation>[];

Expand Down Expand Up @@ -276,9 +278,9 @@ void main() {
debugDisableShadows = true;
});

testWidgets('Banner widget in MaterialApp', (WidgetTester tester) async {
testWidgets('Banner widget in WidgetsApp', (WidgetTester tester) async {
debugDisableShadows = false;
await tester.pumpWidget(const MaterialApp(home: Placeholder()));
await tester.pumpWidget(const TestWidgetsApp(home: Placeholder()));
expect(
find.byType(CheckedModeBanner),
paints
Expand Down