flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
163.11k stars 26.83k forks source link

Provide an API to update query parameters #107279

Open guidezpl opened 1 year ago

guidezpl commented 1 year ago

It's currently fairly easy and straightforward to use parsed query parameters to change UI through go_router.

Consider the case where we'd like user input or some state to be reflected in the URL as a query parameter. For example, a user clicks a brightness button, and we'd want to add to or update the URL to show &brightness=dark.

In my case, I found that pushing an identical route with a query parameter triggered an infinite refresh loop.

NeroThroN commented 1 year ago

I only realized today that this functionality does not yet exist when I would need it. I would like to bring the focus back to center stage with a new example.

For example, refreshing the query parameters could allow us to sync the url with a search screen. Like Youtube when the text input is submitted the input value is stored inside the url (https://www.youtube.com/results?search_query=flutter) but with the difference that in this case the screen is the same so animations and state are not reset.

lucasoares commented 11 months ago

I only realized today that this functionality does not yet exist when I would need it. I would like to bring the focus back to center stage with a new example.

For example, refreshing the query parameters could allow us to sync the url with a search screen. Like Youtube when the text input is submitted the input value is stored inside the url (https://www.youtube.com/results?search_query=flutter) but with the difference that in this case the screen is the same so animations and state are not reset.

It is precisely my use case. It's sad this doesn't exists. And I'm not using go-router or anything like that, I just want to put the search keyword in the URL.