Skip to content

Conversation

chunhtai
Copy link
Contributor

Description

The navigator refactor accidentally changes the contract of navigator observer. If there are multiple route added in one history update (for example adding initial routes), the observer will receive the notifications from top-most route to bottm-most routes. It is the opposite of the order before the navigator observation.

This pr fixes it.

Related Issues

Fixes #57407 (comment)

Tests

I added the following tests:

See files

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label May 19, 2020
@chunhtai chunhtai requested a review from goderbauer May 27, 2020 21:31
@chunhtai
Copy link
Contributor Author

chunhtai commented Jun 4, 2020

@goderbauer This is somehow blocking the hero refactor since it touches the navigator observer

Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe call this flushObserverNotifications? (similarly to the _flushRouteAnnouncement below).

Copy link
Member

Choose a reason for hiding this comment

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

As an idea: maybe use a polymorphic approach:

  • remove this enum
  • have an abstract void notify(List<Observers> observers) on _NavigatorObservation
  • have subclasses for the various actions that implement the correct notification dispatch for the observation.

That also avoids the big switch below

@chunhtai
Copy link
Contributor Author

chunhtai commented Jun 5, 2020

ready for another look

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@chunhtai chunhtai merged commit afbb80b into flutter:master Jun 5, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
* fix navigator observer announcement order

* addressing review comments

* update

* fix analyzer
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NavigatorObserver.didPush called in reverse order when using Navigator.initialRoute

4 participants