flutter icon indicating copy to clipboard operation
flutter copied to clipboard

[go_router] Improved URL handling and navigation updates

Open t0uh33d opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

Use case

Currently, when using the go_router package in Flutter for web apps, there are certain scenarios where the URL update and navigation behavior can be improved. This feature request aims to address two specific scenarios:

  1. Updating the URL and displaying the current navigation item without rebuilding the entire page: Currently, when using the go_router's shell route, the entire page is rebuilt when updating the URL to display the current navigation item. This can result in unnecessary overhead and performance issues, especially when working with complex web apps. The requested feature aims to provide a more efficient solution that updates only the necessary components or windows where the menu should be changed, without rebuilding the entire page.

  2. Handling multiple tab bars and updating the URL accordingly: In certain cases, there might be screens that contain multiple tab bars with different options. The current behavior of go_router does not support updating the URL dynamically based on tab selection. The requested feature aims to enhance go_router's functionality to handle scenarios where the URL needs to be updated as users switch between different tabs within a screen. Specifically, when a user selects a tab, the URL should be updated to reflect the current tab selection, allowing for easy bookmarking and sharing of specific tab states.

This feature enhancement would greatly improve the user experience and make it easier to build and navigate web apps using Flutter and go_router. By providing more granular control over URL updates and navigation, developers can create more efficient and user-friendly web applications.

Proposal

To handle the above scenario, I wrote a package that utilizes Change Notifier and JavaScript channels to update the URL based on state changes in Flutter web apps. This integration allows for efficient tracking and management of state changes and ensures synchronized URL updates without the need for page rebuilds or full re-routing.

Considering the technical implementation and benefits of the package, it would be advantageous to consider integrating some of its features into go_router itself. Incorporating these enhancements directly into go_router could provide a native solution for handling URL updates and navigation in Flutter web apps, eliminating the need for developers to rely on separate packages.

Link to the package

t0uh33d avatar May 31 '23 10:05 t0uh33d