lukepighetti / fluro

Fluro is a Flutter routing library that adds flexible routing options like wildcards, named parameters and clear route definitions.
https://pub.dev/packages/fluro
MIT License
3.67k stars 417 forks source link

Problems with changing urls and windows with pending modifications #247

Open ghost opened 3 years ago

ghost commented 3 years ago

Hello, Suppose I have a window with a form, that form has been modified, so the modifications are pending to be saved. Now I open another window changing the url and therefore the current one (which has the modifications) closes, how can I put an alert message to prevent or accept navigating to the new url and accept or cancel the pending modifications in the current form? I have tried to do it through the router.define handler, but it is not async. Is there a standardized method to control this type of situation? Thanks for your help. Regards, Jose

ignertic commented 3 years ago

I think this is something you can achieve in your code. Wherever you trigger the action to switch pages, why not have a modal or dialog show up first before you call Navigator.push

ghost commented 3 years ago

Thanks @ignertic, but it is not that easy. :( If the user changes the url in the browser to go to another page, I can't intercept it or at least I haven't found a way to do it. Thanks.

ignertic commented 3 years ago

What are the ramifications if you try to achieve this with some javascript ?

ghost commented 3 years ago

I don't know, I am not an expert in javascript. :(