3

Flutter Web: Is there a way to make the URLs for an app appear similar to the navigation route name so that we can do deep linking? For e.g. if I run an app now on chrome, the URL I get is "http://localhost:51322/#/". So if I am on the home screen, how can I have it as "http://localhost:51322/#/home"?

I tried the solution at https://medium.com/flutter-community/more-than-a-flutter-web-app-is-a-full-flutter-website-c6bb210b1f16, but it doesn't seem to work anymore.

Samet ÖZTOPRAK
  • 3,112
  • 3
  • 32
  • 33
vzurd
  • 1,416
  • 2
  • 15
  • 37

1 Answers1

0

The section of the url after the # is the "route name" from "named routes" which are explained pretty well here: https://flutter.dev/docs/cookbook/navigation/named-routes

Specifically to change from "/" to "/home" as your default route, you want to change the "initialRoute" parameter to MaterialApp to "/home" and make sure your routes map has an entry for "/home" instead of "/"

There are a few ways to tell MaterialApp what the "home" or "root" Widget is, you will want to be careful that you don't give it conflicting instructions. The specifics are in the class documentation: https://api.flutter.dev/flutter/material/MaterialApp-class.html

The Trav
  • 1,955
  • 3
  • 22
  • 30