Skip to content

Conversation

@rkishan516
Copy link
Contributor

@rkishan516 rkishan516 commented Aug 23, 2025

Changes

  • Move PageTransitionsBuilder from material/page_transitions_theme.dart to widget/page_transitions_builder.dart

part of: #172929

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.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Aug 23, 2025
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 the PageTransitionsBuilder class by moving it from packages/flutter/lib/src/material/page_transitions_theme.dart to a new file packages/flutter/lib/src/widgets/page_transitions_builder.dart. This is a good architectural improvement, placing the general-purpose builder in a lower-level library. The changes are clean and the existing tests should cover this refactoring. I've added a couple of suggestions to improve the documentation in the new file to better reflect its new, more generic location.

Comment on lines 13 to 50
/// Used by [PageTransitionsTheme] to define a [MaterialPageRoute] page
/// transition animation.
///
/// Apps can configure the map of builders for [ThemeData.pageTransitionsTheme]
/// to customize the default [MaterialPageRoute] page transition animation
/// for different platforms.
///
/// See also:
///
/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition
/// that's similar to the one provided by Android O.
/// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition
/// that's similar to the one provided by Android P.
/// * [ZoomPageTransitionsBuilder], which defines the default page transition
/// that's similar to the one provided in Android Q.
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
/// transition that matches native iOS page transitions.
/// * [FadeForwardsPageTransitionsBuilder], which defines a page transition
/// that's similar to the one provided by Android U.
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Since PageTransitionsBuilder is now in the widgets library, its documentation should be more generic and not solely focused on its usage within the material library.1

I suggest updating the class documentation to first provide a general description and then specify its use in material. Also, adding PageTransitionsTheme and MaterialPageRoute to the "See also" section would provide better context for developers.

/// Defines a page transition animation for a [PageRoute].
///
/// This class is used by [PageTransitionsTheme] to define a [MaterialPageRoute]
/// page transition animation. Apps can configure the map of builders for
/// [ThemeData.pageTransitionsTheme] to customize the default
/// [MaterialPageRoute] page transition animation for different platforms.
///
/// See also:
///
///  * [PageTransitionsTheme], which uses this class to configure page transitions.
///  * [MaterialPageRoute], which uses this class to build its transition.
///  * [FadeUpwardsPageTransitionsBuilder], which defines a page transition
///    that's similar to the one provided by Android O.
///  * [OpenUpwardsPageTransitionsBuilder], which defines a page transition
///    that's similar to the one provided by Android P.
///  * [ZoomPageTransitionsBuilder], which defines the default page transition
///    that's similar to the one provided in Android Q.
///  * [CupertinoPageTransitionsBuilder], which defines a horizontal page
///    transition that matches native iOS page transitions.
///  * [FadeForwardsPageTransitionsBuilder], which defines a page transition
///    that's similar to the one provided by Android U.

Style Guide References

Footnotes

  1. Documentation should be useful and explain the 'why' and 'how'. The suggested change improves the documentation's usefulness by clarifying the class's general purpose before its specific application, which is better for a class in a lower-level library. (link)

Copy link
Contributor

@victorsanni victorsanni Aug 29, 2025

Choose a reason for hiding this comment

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

+1

Comment on lines 52 to 80
/// Wraps the child with one or more transition widgets which define how [route]
/// arrives on and leaves the screen.
///
/// The [MaterialPageRoute.buildTransitions] method looks up the
/// current [PageTransitionsTheme] with `Theme.of(context).pageTransitionsTheme`
/// and delegates to this method with a [PageTransitionsBuilder] based
/// on the theme's [ThemeData.platform].
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The documentation for buildTransitions is very specific to its usage in MaterialPageRoute. To improve clarity and adhere to better layering, I suggest making the documentation more general first, explaining the method's purpose, and then providing the MaterialPageRoute usage as an example.1

  /// Wraps the child with one or more transition widgets which define how [route]
  /// arrives on and leaves the screen.
  ///
  /// Subclasses override this method to create a transition animation.
  ///
  /// The [MaterialPageRoute.buildTransitions] method is an example of a method
  /// that uses this to build a transition. It looks up the current
  /// [PageTransitionsTheme] with `Theme.of(context).pageTransitionsTheme`
  /// and delegates to this method with a [PageTransitionsBuilder] based
  /// on the theme's [ThemeData.platform].

Style Guide References

Footnotes

  1. Documentation should be useful and explain the 'why' and 'how'. The current documentation is too specific to one implementation. The suggestion makes it more general and useful by explaining the method's core purpose first. (link)

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 here

Copy link
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

I would avoid design-language-specific documentation and references (Material, Theme and ThemeData etc). Try to make this as standalone and as design-language-agnostic as possible. Instead, move the Material-specific documentation to the relevant Material widgets.

@dkwingsmt dkwingsmt requested review from dkwingsmt and removed request for dkwingsmt August 27, 2025 18:37
@victorsanni
Copy link
Contributor

I would avoid design-language-specific documentation and references (Material, Theme and ThemeData etc). Try to make this as standalone and as design-language-agnostic as possible. Instead, move the Material-specific documentation to the relevant Material widgets.

I asked offline and found this is not entirely true. Referencing Material APIs in widgets documentation is okay, as long as it is used as an example of a design-language-specific implementation (vs. treating Material like a first-class citizen).

Copy link
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

The documentation suggestions from gemini look like a good place to start.

Also are there tests for this class that can be moved here? I don't think we want to add a new file + class in widgets/ without some sort of test.

@rkishan516 rkishan516 force-pushed the page-transitions-builder branch from 0fc4d18 to b74aecf Compare August 30, 2025 01:04
@rkishan516
Copy link
Contributor Author

I don't think there are tests for PageTransitionsBuilder. But what kind of new tests we want to add?

@victorsanni
Copy link
Contributor

I don't think there are tests for PageTransitionsBuilder. But what kind of new tests we want to add?

A test could make a mock transitions builder that extends PageTransitionsBuilder and verify that it works.

@rkishan516 rkishan516 force-pushed the page-transitions-builder branch from b74aecf to 21cee4d Compare September 5, 2025 04:20
@victorsanni
Copy link
Contributor

Approach with test so far is looking good. Can you adopt the gemini doc recommendations and fix the failing tests in CI?

@rkishan516 rkishan516 force-pushed the page-transitions-builder branch 2 times, most recently from 8a2a6e8 to 37a9080 Compare September 5, 2025 17:06
@rkishan516 rkishan516 force-pushed the page-transitions-builder branch from 37a9080 to 907ca6f Compare September 9, 2025 15:05
Copy link
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

Looking good so far, one final comment asking for more documentation.

@rkishan516 rkishan516 force-pushed the page-transitions-builder branch from 907ca6f to 313d4b2 Compare September 11, 2025 01:16
@rkishan516
Copy link
Contributor Author

@victorsanni I have updated the paragraph, please have a look.

scale: Tween<double>(
begin: 0.5,
end: 1.0,
).animate(CurvedAnimation(parent: animation, curve: Curves.easeInOut)),
Copy link
Contributor

Choose a reason for hiding this comment

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

this might be causing a memory leak, consider using CurveTween or something similar instead.

/// in any design system. Custom [PageRoute] subclasses can accept a
/// PageTransitionsBuilder and delegate to its [buildTransitions] method when
/// overriding [ModalRoute.buildTransitions]. This enables reusable transition
/// animations that work with [Navigator] and other navigation primitives without
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we need to explicitly say "without requiring Material Design components". The idea is the class should be understandable as a standalone concept for developers who don't even know Material exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

So this should precede the paragraph on PageTransitionsTheme, while that paragraph should be prefixed with an annotation that it is an example of how this class can be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, Make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have pushed snipped directly in doc, right now. Do you feel, we should create a example file for this?

@rkishan516 rkishan516 force-pushed the page-transitions-builder branch 2 times, most recently from 383ab98 to d3c5c97 Compare September 15, 2025 02:09
@github-actions github-actions bot added d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Sep 15, 2025
@rkishan516 rkishan516 force-pushed the page-transitions-builder branch from d3c5c97 to 69bd510 Compare September 15, 2025 10:06
Copy link
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

To fix linux analyze, run dart format packages/flutter/test/widgets/page_transitions_builder_test.dart

@rkishan516 rkishan516 force-pushed the page-transitions-builder branch from 3872487 to 04b7698 Compare September 16, 2025 23:07
@MitchellGoodwin MitchellGoodwin added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 17, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Sep 17, 2025
Merged via the queue into flutter:master with commit de932b3 Sep 17, 2025
77 of 78 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 17, 2025
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
…74321)

Changes
* Move PageTransitionsBuilder from
`material/page_transitions_theme.dart` to
`widget/page_transitions_builder.dart`

part of: flutter#172929

## 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 `///`).
- [ ] 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.
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 21, 2025
…74321)

Changes
* Move PageTransitionsBuilder from
`material/page_transitions_theme.dart` to
`widget/page_transitions_builder.dart`

part of: flutter#172929

## 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 `///`).
- [ ] 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.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…74321)

Changes
* Move PageTransitionsBuilder from
`material/page_transitions_theme.dart` to
`widget/page_transitions_builder.dart`

part of: flutter#172929

## 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 `///`).
- [ ] 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants