Skip to content

Remove Material import from navigator_on_did_remove_page_test#184776

Open
xfce0 wants to merge 1 commit intoflutter:masterfrom
xfce0:fix-navigator-on-did-remove-page-material-import
Open

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

Conversation

@xfce0
Copy link
Copy Markdown
Contributor

@xfce0 xfce0 commented Apr 8, 2026

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

  Part of flutter#177414.

  Replaces MaterialPage with a local _TestPage helper and
  MaterialPageRoute with PageRouteBuilder, removing the unnecessary
  dependency on package:flutter/material.dart.
  Also removes the file from the knownWidgetsCrossImports allowlist.
@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
Copy link
Copy Markdown
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 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');
},
),

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.

1 participant