Skip to content

Update API docs to include example of how to get current Route #14243

Closed

Description

@xster

Add a Route<> current() or a bool isCurrent(Route) API to NavigatorState

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: routesNavigator, Router, and related APIs.
    on Jan 24, 2018
  2. xqwzts commented on Jan 26, 2018

    @xqwzts
    Contributor

    @xster I picked this up, it seemed a simple enough solution to expose NavigatorState's _history.last property with a getter. Did you have something else in mind?

  3. xster commented on Jan 26, 2018

    @xster
    MemberAuthor

    @Hixie may have some existing mental picture of what he wants to do

  4. Hixie commented on Jan 29, 2018

    @Hixie
    Contributor

    Can you elaborate on the use case here? Why is ModalRoute.of(context).isCurrent sufficient, for instance?

  5. xster commented on Jan 29, 2018

    @xster
    MemberAuthor

    I think it is. Might just be a matter of documentation and convenience.

  6. sroddy commented on Jan 29, 2018

    @sroddy
    Contributor

    What if the route is not a ModalRoute and the widget can be added in different routes?

  7. Hixie commented on Jan 30, 2018

    @Hixie
    Contributor

    Can you give an example?

    How would you use the new API? (e.g. how would you be notified if the current route changed, or if the current widget was moved to another route?)

  8. changed the title [-]Add a current() API to NavigatorState[/-] [+]Document how to get current Route[/+] on Dec 28, 2018
  9. vmwsree commented on Feb 9, 2019

    @vmwsree

    Hi In my Case in a chat app , the user should get a notification for all the messages on the screen except the active chat, So I have to check if the current route is equal to the notification I received, if so ignore else show.

  10. added this to the milestone on Feb 11, 2019
  11. dspoonia7 commented on Feb 25, 2019

    @dspoonia7

    Any updates on this, Need this as I have exactly the same use case as @vmwsree has mentioned above.
    But in addition to not show notification for the active chat, I also want to cancel all the notifications if chat-app home screen (list of all chat) widget is visible in the viewport.
    @xster @zoechi

    Any work around for time being is appreciated. Thanks!!

  12. vmwsree commented on Feb 26, 2019

    @vmwsree

    Rather than title saying Document how to get current Route, I don't think there is a feature to fetch the current route or its type, this is a framework requirement

  13. Ikxyz commented on Mar 2, 2019

    @Ikxyz

    To get the exact route name eg /home use

    import 'package:path/path.dart';

    ModalRoute.of(context).settings.name

    @xster @zoechi @vmwsree

  14. 41 remaining items

  15. tmushayahama commented on Nov 22, 2022

    @tmushayahama

    November 2022 and 4 years later no resolution to this. I thought this was a common functionality in most frameworks,

  16. changed the title [-]Document how to get current Route[/-] [+]Update API docs to include example of how to get current Route[/+] on Nov 24, 2022
  17. Hixie commented on Nov 24, 2022

    @Hixie
    Contributor

    @tmushayahama This issue is just about updating the API docs. If you have a use case that is not currently handled, I encourage you to file a new bug. If you would like to help us, then you are welcome to do so; Flutter is an open source project.

    @Saad29 That's a PR for a different issue (it doesn't change the documentation), and it looks like Victor decided not to follow it up. You are, however, welcome to file a bug that describes the use case you want to address and then you are welcome to use that PR as the start of a patch to address your use case.

  18. self-assigned this
    on Mar 16, 2023
  19. github-actions commented on Apr 6, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  20. locked as resolved and limited conversation to collaborators on Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/f: routesNavigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions