Yeb03
Yeb03

Reputation: 45

How does Flutter web handle manually typed URLs? I'm experiencing weird behaviours

I have a Flutter web project up and running. Everything is working fine.

However, while testing new pages I just added, I noticed that although I can succesfully reach my new routes by clicking on the links that redirect to them, I sometimes cannot reach them if I type the URL manually in the address bar.

Sometimes, it just takes me back to the home route. This seems to be happening in Chrome more than in Firefox.

I also noticed that after being unable to reach, for example, 'https://mysite/#newpage' if I click the address bar and I type a purposefully wrong URL by omitting the '#' (so 'https://mysite/newpage') and I hit enter, Flutter redirects me to the homepage but the url in the address bar changes to 'https://mysite/newpage#/'. Now, if I manually correct the URL by deleting the trailng slash and moving the '#' right before 'newpage' (so the URL looks like this: 'https://mysite/#newpage'), it correctly takes me to the desired page despite it being the exact same correct but unreachable address previously typed. This trick works 100% of the times.

As I mentioned before, links and redirects do not have this problem as they always take me to the correct page on the first attempt. This happens only when I type the URL manually.

So my question is:

How does Flutter handle URLs manually typed by the user? Is there anything special about it I need to be aware of? Or am I just missing something incredibly obvious?

Thank you

Upvotes: 2

Views: 503

Answers (0)

Related Questions