How to remove # symbol from flutter web app url

Issue

As the time am asking this question, is there any official or an update that enables me to remove the # symbol in the flutter web app url.

I have seen some work arounds to achieve this but they end up causing other issues like: people not able to access the webpage without the hash # in the url

Solution

From this answer

There is a package call url_strategy in pub.dev. You only need to import in into pubspec.yaml and copy the code below into your main.dart file. It will remove the # in your flutter web URL

import 'package:url_strategy/url_strategy.dart';

void main() {
  // Here we set the URL strategy for our web app.
  // It is safe to call this function when running on mobile or desktop as well.
  setPathUrlStrategy();
  runApp(MyApp());
}

Answered By – Tjandra Darmo

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.