Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the url in Flutter web?

I need to change the content of this web page

enter image description here

for this content enter image description here

And also change the url from "localhost:49318/#/home/inicio" to "localhost:49318/#/home/other".

All of this without using the Navigator.

In a mobile app I would change the widget shown with a set state, but doing that on a web page wouldn't change the url.

like image 600
Ezequiel Avatar asked Dec 18 '19 22:12

Ezequiel


1 Answers

I use Fluro (a package) to control my routes, but eventually I need to change the URL without redirecting.

The solution is pretty simple

Import this:

import 'dart:html' as html;

Then in your code, use this to change the URL without affecting the current page

html.window.history.pushState(null, 'home', '#/home/other');
like image 126
Fernando Herrera Avatar answered Oct 01 '22 18:10

Fernando Herrera