Skip to content

Feat: Add opaque, isActive, isFirst, popDisposition aspects for ModalRoute #167324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2025

Conversation

rkishan516
Copy link
Contributor

@rkishan516 rkishan516 commented Apr 17, 2025

Feat: Add opaque, isActive, isFirst, popDisposition aspects for ModalRoute
fixes: #167058
fixes: #162009

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 framework flutter/packages/flutter repository. See also f: labels. f: routes Navigator, Router, and related APIs. labels Apr 17, 2025
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.

See my comment about more tests, otherwise I think this looks good. I like encouraging the use of InheritedModel for performance.

@@ -2509,6 +2509,35 @@ void main() {
moreOrLessEquals(xLocationIntervalTwelve, epsilon: 0.1),
);
});

testWidgets('ModalRoute.isFirstOf only rebuilds when first route state changes', (
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind adding a similar test for each of the other of methods that you added as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will add.

@rkishan516 rkishan516 force-pushed the modal-route-aspects branch from 288d8ac to 721d47a Compare April 23, 2025 01:40
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.

Thanks for adding all the tests. One comment about the docs, otherwise this looks good.

It seems like this should be merged regardless of the outcome of your PR #165289, right?

@@ -1321,6 +1341,24 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
static RouteSettings? settingsOf(BuildContext context) =>
_of(context, _ModalRouteAspect.settings)?.settings;

/// Returns [ModalRoute.isActive] for the modal route most closely associated
/// with the given context.
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that settingsOf and others above include a bit more in their docs, should you add them for the new parameters too?

  /// Returns null if the given context is not associated with a modal route.
  ///
  /// Use of this method will cause the given [context] to rebuild any time that
  /// the [ModalRoute.settings] property of the ancestor [_ModalScopeStatus] changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, thanks for the suggestion.

Copy link
Contributor

@dkwingsmt dkwingsmt May 21, 2025

Choose a reason for hiding this comment

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

We should not mention _ModalScopeStatus in the doc since it's a private widget.

I also consulted with AI, who said the original version might be slightly ambiguous (since the reader might the the BuildContext itself would be rebuilt) and suggested the following. What do you think?

/// Calling this method creates a dependency on the [ModalRoute] associated
/// with the given [context]. As a result, the widget corresponding to [context]
/// will be rebuilt whenever the route's [ModalRoute.settings] changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with not mentioning private members and I like the rewrite 👍

@rkishan516
Copy link
Contributor Author

It seems like this should be merged regardless of the outcome of your PR #165289, right?

I don't know. Because if we switch to selector pattern, than these will become just helper methods and soon we need to deprecate. I will rather wait for #165289, that which direction it will go and based on that take a call on this. Wdyt ?

@rkishan516 rkishan516 force-pushed the modal-route-aspects branch from 721d47a to a1e40d0 Compare April 30, 2025 01:06
@navaronbracke
Copy link
Contributor

@rkishan516 This should also fix #162009 right? You can add that to the OP then.

@rkishan516
Copy link
Contributor Author

@rkishan516 This should also fix #162009 right? You can add that to the OP then.

Done, have updated.

@justinmc
Copy link
Contributor

justinmc commented May 5, 2025

It seems like this should be merged regardless of the outcome of your PR #165289, right?

I don't know. Because if we switch to selector pattern, than these will become just helper methods and soon we need to deprecate. I will rather wait for #165289, that which direction it will go and based on that take a call on this. Wdyt ?

Ok I agree, let's wait for #165289. So this PR can stay open for now. I'll prioritize reviewing that one.

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 👍

It looks like #165289 maybe stalled out so I want to LGTM this in case we want to merge this without it. There are a few PRs that depend on this one now: #167032, #168277

@rkishan516
Copy link
Contributor Author

It looks like #165289 maybe stalled out so I want to LGTM this in case we want to merge this without it. There are a few PRs that depend on this one now: #167032, #168277

Yes @justinmc, I don't think we will be going towards selector, so it make sense to merge this.

@justinmc justinmc requested a review from dkwingsmt May 20, 2025 22:11
Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM except for the doc

@@ -1321,6 +1341,24 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
static RouteSettings? settingsOf(BuildContext context) =>
_of(context, _ModalRouteAspect.settings)?.settings;

/// Returns [ModalRoute.isActive] for the modal route most closely associated
/// with the given context.
Copy link
Contributor

@dkwingsmt dkwingsmt May 21, 2025

Choose a reason for hiding this comment

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

We should not mention _ModalScopeStatus in the doc since it's a private widget.

I also consulted with AI, who said the original version might be slightly ambiguous (since the reader might the the BuildContext itself would be rebuilt) and suggested the following. What do you think?

/// Calling this method creates a dependency on the [ModalRoute] associated
/// with the given [context]. As a result, the widget corresponding to [context]
/// will be rebuilt whenever the route's [ModalRoute.settings] changes.

@rkishan516 rkishan516 force-pushed the modal-route-aspects branch from a1e40d0 to 27bfdc5 Compare May 22, 2025 01:39
@rkishan516
Copy link
Contributor Author

We should not mention _ModalScopeStatus in the doc since it's a private widget.

I have updated the docs based on your suggestion.

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.

Renewing my LGTM 👍 .

#165289 was closed so I'll add autosubmit here.

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label May 29, 2025
@auto-submit auto-submit bot added this pull request to the merge queue May 29, 2025
Merged via the queue into flutter:master with commit df29894 May 29, 2025
76 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 29, 2025
salemiranloye pushed a commit to salemiranloye/flutter that referenced this pull request May 29, 2025
…Route (flutter#167324)

Feat: Add opaque, isActive, isFirst, popDisposition aspects for
ModalRoute
fixes: flutter#167058 
fixes: flutter#162009 

## 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.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2025
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.

ModalRoute lacks aspect for opaque property Allow depending on ModalRoute.popDispositionOf(context)
4 participants