Skip to content

Remove Material import from navigator_on_did_remove_page_test#184776

Closed
xfce0 wants to merge 0 commit into
flutter:masterfrom
xfce0:fix-navigator-on-did-remove-page-material-import
Closed

Remove Material import from navigator_on_did_remove_page_test#184776
xfce0 wants to merge 0 commit into
flutter:masterfrom
xfce0:fix-navigator-on-did-remove-page-material-import

Conversation

@xfce0

@xfce0 xfce0 commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Part of #177414.

Replaces MaterialPage with a local _TestPage helper and MaterialPageRoute with PageRouteBuilder, removing the unnecessary dependency on package:flutter/material.dart from a widgets-layer test.

Also removes the file from the knownWidgetsCrossImports allowlist in dev/bots/check_tests_cross_imports.dart.

Pre-launch Checklist

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: routes Navigator, Router, and related APIs. labels Apr 8, 2026

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

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.

Code Review

This pull request removes a test file from the cross-import checker and updates the navigator test to use a custom _TestPage implementation instead of MaterialPage. The review feedback suggests adding documentation to the new helper class and ensuring consistent animation durations in the PageRouteBuilder for test performance.

Comment on lines +8 to +11
class _TestPage extends Page<void> {
const _TestPage({required super.key, required this.child});

final Widget child;

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.

medium

According to the Flutter style guide, all members (including private ones) should have public-quality documentation using ///. Adding documentation helps explain the purpose of this test helper class and its fields.

/// A [Page] implementation used for testing the [Navigator].
class _TestPage extends Page<void> {
  /// Creates a [_TestPage].
  const _TestPage({required super.key, required this.child});

  /// The widget to display as the content of the page.
  final Widget child;
References
  1. Use /// for public-quality documentation, even on private members. (link)

Comment on lines +109 to 113
PageRouteBuilder<void>(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return const Text('new page');
},
),

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.

medium

For consistency with _TestPage and to ensure the test remains fast and deterministic, consider setting transitionDuration and reverseTransitionDuration to Duration.zero here as well. This avoids unnecessary animation delays during the test execution.

Suggested change
PageRouteBuilder<void>(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return const Text('new page');
},
),
PageRouteBuilder<void>(
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return const Text('new page');
},
),

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'm not sure whether this has an actual effect on test execution time, but probable worth trying it.

@justinmc justinmc left a comment

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.

Thanks for the PR! Take a look at using the existing TestPage here. I think it was added recently, my fault for the delay in reviewing this PR.

Also heads up that there is an analyzer failure.

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

class _TestPage extends Page<void> {

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.

Could this use this shared utility?

class TestPage<T> extends Page<T> {

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.

Done — replaced the local _TestPage with the shared TestPage<void> from test_page_tester.dart.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 29, 2026

@justinmc justinmc left a comment

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.

LGTM, thanks! 👍

Comment on lines +109 to 113
PageRouteBuilder<void>(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return const Text('new page');
},
),

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'm not sure whether this has an actual effect on test execution time, but probable worth trying it.

@justinmc justinmc added the CICD Run CI/CD label Apr 29, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@xfce0 xfce0 closed this Apr 29, 2026
@xfce0 xfce0 force-pushed the fix-navigator-on-did-remove-page-material-import branch from 0179e25 to 2150dfd Compare April 29, 2026 20:49
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants