skip to Main Content

When the user is moving around in my Flutter application, I wish to be able to track where the user goes and how they reach it. For now, it seems that the router would be updated when a user is navigating from one page to another, but opening a dialog won’t trigger anything.

I have asked ChatGPT and it suggests me to add something to the state management tool to record which dialog is opened. But since there’re already a lot of dialogs in my application, it feels to be a huge work and I wish to find a way to build a function that can automatically detect the dialog that has been opened, perhaps based on its GlobalKey to identify it.

Have checked the Flutter doc but haven’t found anything yet. Could anyone help me out on this? Thanks in advance!

My application uses go_router, by the way. I also wonder if there’s a way to manage the dialogs by route.

2

Answers


  1. I think you can use Getx state management. As Getx has its own tracking page routes. It also has built in dialogs and bottom sheets. When that page or dialog opens up in debug console there show route.
    I hope you want to track pages and dialogs in debug mood.

    Login or Signup to reply.
  2. The answer to your question involves combining insights from several existing solutions.

    To track whether a dialog is opened in Flutter, there are multiple approaches you can consider. Some useful methods are discussed in this post, including using Boolean flags and leveraging GlobalKeys.

    Regarding your inquiry about managing dialogs as routes in go_router, you can refer to this post. Additionally, if you need to track the current location in go_router, you might find this answer helpful.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search