Skip to content

Refactor: Remove material from ticker provider test#181697

Merged
auto-submit[bot] merged 3 commits intoflutter:masterfrom
rkishan516:ticker-provider-cross-imports
Feb 24, 2026
Merged

Refactor: Remove material from ticker provider test#181697
auto-submit[bot] merged 3 commits intoflutter:masterfrom
rkishan516:ticker-provider-cross-imports

Conversation

@rkishan516
Copy link
Contributor

@rkishan516 rkishan516 commented Jan 30, 2026

This PR removes Material imports from ticker_provider_test.dart.

part of: #177415
depends on: #181695

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Jan 30, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors ticker_provider_test.dart to remove its dependency on the Material library, which is a good improvement for isolating tests. This is achieved by introducing a new _TickerWidget for testing purposes and enhancing TestWidgetsApp to support routes and custom transitions, replacing MaterialApp. The changes are well-implemented and include comprehensive tests for the new functionality in TestWidgetsApp. I've added one suggestion to improve the maintainability of the new test code by reducing duplication.

Comment on lines +215 to +241
testWidgets('routes can be navigated with pushNamed', (WidgetTester tester) async {
await tester.pumpWidget(
TestWidgetsApp(
home: Builder(
builder: (BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/details');
},
child: const Text('Home Page'),
);
},
),
routes: <String, WidgetBuilder>{
'/details': (BuildContext context) => const Text('Details Page'),
},
),
);

expect(find.text('Home Page'), findsOneWidget);
expect(find.text('Details Page'), findsNothing);

await tester.tap(find.text('Home Page'));
await tester.pumpAndSettle();

expect(find.text('Details Page'), findsOneWidget);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's significant duplication in the setup for the new navigation-related tests. Each test re-creates a TestWidgetsApp with a similar home widget (Builder with a GestureDetector).

To improve maintainability and reduce boilerplate, consider extracting this common setup into a helper function. This would make the tests cleaner and easier to read.

For example, you could create a helper within the test group:

Future<void> _pumpNavigationTestApp(
  WidgetTester tester, {
  required Map<String, WidgetBuilder> routes,
  Widget? home,
  RouteTransitionsBuilder? transitionsBuilder,
}) {
  return tester.pumpWidget(
    TestWidgetsApp(
      home: home ?? Builder(
        builder: (BuildContext context) {
          return GestureDetector(
            onTap: () => Navigator.of(context).pushNamed('/details'),
            child: const Text('Home Page'),
          );
        },
      ),
      routes: routes,
      if (transitionsBuilder != null) transitionsBuilder: transitionsBuilder,
    ),
  );
}

Then, this test could be simplified to:

testWidgets('routes can be navigated with pushNamed', (WidgetTester tester) async {
  await _pumpNavigationTestApp(
    tester,
    routes: <String, WidgetBuilder>{
      '/details': (BuildContext context) => const Text('Details Page'),
    },
  );

  expect(find.text('Home Page'), findsOneWidget);
  expect(find.text('Details Page'), findsNothing);

  await tester.tap(find.text('Home Page'));
  await tester.pumpAndSettle();

  expect(find.text('Details Page'), findsOneWidget);
});

@rkishan516 rkishan516 force-pushed the ticker-provider-cross-imports branch 5 times, most recently from 9504338 to 61b3ce0 Compare January 31, 2026 03:21
@rkishan516 rkishan516 force-pushed the ticker-provider-cross-imports branch from 61b3ce0 to 1393808 Compare February 5, 2026 02:09
@rkishan516 rkishan516 marked this pull request as draft February 5, 2026 02:09
@rkishan516 rkishan516 force-pushed the ticker-provider-cross-imports branch 2 times, most recently from f3eafbc to 7e90327 Compare February 17, 2026 02:03
@rkishan516 rkishan516 marked this pull request as ready for review February 17, 2026 02:04
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully removes the dependency on the Material library from ticker_provider_test.dart. It replaces Material-specific widgets like CircularProgressIndicator, LinearProgressIndicator, and MaterialApp with a custom _TickerWidget and TestWidgetsApp (a WidgetsApp wrapper). This refactoring aligns with the project's goal of keeping the Widgets library and its tests independent of design-specific libraries like Material or Cupertino. The test logic remains intact and correctly verifies TickerMode behavior and navigation interactions. The removal of the test file from the knownWidgetsCrossImports list in check_tests_cross_imports.dart ensures that no new Material dependencies will be accidentally introduced to this test in the future.

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #181697 at sha 7e90327

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Feb 17, 2026
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍

}

/// A widget that creates and runs a ticker for testing purposes.
class _TickerWidget extends StatefulWidget {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this helper. If we need it elsewhere later we can think about making it public somewhere.

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 19, 2026
@justinmc justinmc moved this from Todo to Done in Test cross-imports Review Queue Feb 19, 2026
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 20, 2026
@auto-submit
Copy link
Contributor

auto-submit bot commented Feb 20, 2026

auto label is removed for flutter/flutter/181697, Failed to enqueue flutter/flutter/181697 with HTTP 400: GraphQL mutate failed.

@rkishan516 rkishan516 force-pushed the ticker-provider-cross-imports branch from f7fb205 to 79e9e76 Compare February 22, 2026 03:28
@rkishan516 rkishan516 added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 24, 2026
@auto-submit auto-submit bot added this pull request to the merge queue Feb 24, 2026
Merged via the queue into flutter:master with commit b13a8b2 Feb 24, 2026
152 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2026
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Feb 26, 2026
Roll Flutter from dad6f9d4107a to b31548feb941 (39 revisions)

flutter/flutter@dad6f9d...b31548f

2026-02-25 [email protected] [web] Fix failure on Firefox 148 (flutter/flutter#182855)
2026-02-25 [email protected] Roll Fuchsia Linux SDK from KfPgw04T0OEADLJA5... to XI0Ax7fbtYE4XKYAQ... (flutter/flutter#182887)
2026-02-25 [email protected] Use AnimationStyle curve and reverseCurve in ModalBottomSheet animation (flutter/flutter#181403)
2026-02-25 [email protected] Roll Dart SDK from fd3dce5b6a4e to 5c57e75f1102 (9 revisions) (flutter/flutter#182801)
2026-02-25 98614782+auto-submit[bot]@users.noreply.github.com Reverts "refactor: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (#182697)" (flutter/flutter#182879)
2026-02-25 [email protected] Make sure that an AnimatedSlide doesn't crash in 0x0 environment (flutter/flutter#181535)
2026-02-24 [email protected] Reland Standardize on Test* widgets in *_tester.dart files (flutter/flutter#182632)
2026-02-24 [email protected] docs(Path): clarify that zero-length contours are excluded from computeMetrics (flutter/flutter#180165)
2026-02-24 [email protected] Fix typo in assert message (flutter/flutter#182843)
2026-02-24 [email protected] [win32] Fix overflow in TaskRunnerWindow. (flutter/flutter#182822)
2026-02-24 [email protected] feat: Add --no-uninstall flag to flutter test for integration tests (flutter/flutter#182714)
2026-02-24 [email protected] Rename noFrequencyBasedMinification to useFrequencyBasedMinification (flutter/flutter#182684)
2026-02-24 [email protected] [Impeller] Fix fail to render pixel buffer texture on Linux (flutter/flutter#181656)
2026-02-24 [email protected] Remove FlutterFramework app migration (flutter/flutter#182100)
2026-02-24 [email protected] Roll Packages from 12b43a1 to 062c8d4 (5 revisions) (flutter/flutter#182839)
2026-02-24 [email protected] [web] Run webparagraph tests in CI (flutter/flutter#182092)
2026-02-24 [email protected] Fix a race in EmbedderTest.CanSpecifyCustomUITaskRunner (flutter/flutter#182649)
2026-02-24 [email protected] flutter_tools: Use a super-parameter in several missed cases (flutter/flutter#182581)
2026-02-24 [email protected] Replace more references to `flutter/engine` with `flutter/flutter` (flutter/flutter#182654)
2026-02-24 [email protected] Carousel: Migration from Scrollable+Viewport to CustomScrollView (flutter/flutter#182475)
2026-02-24 [email protected] Refactor impellerc_main to better organize some of its logic (flutter/flutter#182783)
2026-02-24 [email protected] Remove unused `getPluginList ` (flutter/flutter#182660)
2026-02-24 [email protected] Refactor: Remove material from ticker provider test (flutter/flutter#181697)
2026-02-24 [email protected] Roll Skia from 26eebffe12bd to f44d7db68805 (3 revisions) (flutter/flutter#182821)
2026-02-24 [email protected] refactor: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (flutter/flutter#182697)
2026-02-24 [email protected] Roll Skia from 7dad66aae75a to 26eebffe12bd (5 revisions) (flutter/flutter#182810)
2026-02-24 [email protected] Update roadmap for 2026 (flutter/flutter#182798)
2026-02-24 [email protected] Marks Windows tool_tests_commands_1_2 to be unflaky (flutter/flutter#179670)
2026-02-23 [email protected] [web] scroll iOS iframe text input into view (flutter/flutter#179759)
2026-02-23 [email protected] Fix textscaler clamp assertion error (flutter/flutter#181716)
2026-02-23 [email protected] Roll Skia from 9a5a3c92c336 to 7dad66aae75a (4 revisions) (flutter/flutter#182779)
2026-02-23 [email protected] Move more getters from userMessages class to the appropriate places (flutter/flutter#182656)
2026-02-23 [email protected] Manual roll Dart SDK from f8fac50475b8 to fd3dce5b6a4e (6 revisions) (flutter/flutter#182768)
2026-02-23 [email protected] Copy Flutter framework to Add to App FlutterPluginRgistrant (flutter/flutter#182523)
2026-02-23 [email protected] Add progress indicator to artifact downloads (flutter/flutter#181808)
2026-02-23 [email protected] Clarify batch release mode requirements (flutter/flutter#182228)
2026-02-23 [email protected] [web] Remove --disable-gpu from flutter chrome tests (flutter/flutter#182618)
2026-02-23 [email protected] running-apps: update running-apps to use Duration.ago() (flutter/flutter#182172)
2026-02-23 [email protected] Refactor bin/ shell scripts for better performance and safety (flutter/flutter#182674)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

...
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Feb 27, 2026
This PR removes Material imports from ticker_provider_test.dart.

part of: flutter#177415
depends on: flutter#181695

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

---------

Co-authored-by: Victor Sanni <[email protected]>
@rkishan516 rkishan516 deleted the ticker-provider-cross-imports branch March 8, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

Development

Successfully merging this pull request may close these issues.

4 participants