Search packages, repositories and app categories

Package detailsv0.3.0

url_strategy

Flutter package that allows setting the web app URL strategy with a single line of code.

AndroidiOSLinuxmacOSWebWindows
30-day downloads
108K
Likes
554
Pub points
160

Install package

flutter pub add url_strategy

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The url_strategy package enables Flutter web applications to use clean, readable URLs by setting the URL strategy with a single line of code. It allows developers to switch between hash-based routing (e.g., /#/home) and path-based routing (e.g., /home), improving SEO and user experience. The package is lightweight and designed specifically for Flutter Web, ensuring seamless integration without additional configuration. It supports all major platforms, including web, Android, iOS, Linux, macOS, and Windows.

Use cases

  • Enabling clean URLs in Flutter web apps
  • Improving SEO for web-based Flutter applications
  • Simplifying navigation in web-only Flutter projects
  • Supporting deep linking in web apps
  • Maintaining consistent routing across platforms

Key features

  • Single-line URL strategy setup
  • Supports both hash and path-based routing
  • Lightweight and minimal overhead
  • Cross-platform compatibility
  • Easy integration with existing Flutter web projects

Suitable for

  • Flutter developers building web apps
  • Projects requiring SEO-friendly URLs
  • Apps using deep linking or shared links
  • Teams prioritizing clean URL structures
  • Developers targeting web deployment

Considerations

  • Only relevant for web deployment
  • Requires proper server configuration for path-based routing
  • Not needed for mobile-only Flutter apps
  • May require backend adjustments for production hosting
  • Limited utility outside of web contexts

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

url_strategy Pub version

⚠️ Discontinued: The functionality is now provided by the flutter SDK out of the box:

https://docs.flutter.dev/ui/navigation/url-strategies

Package for Flutter apps that allows setting the web URL strategy with a single line of code.

Usage

With a simple call of setPathUrlStrategy, your Flutter web app does not have a leading # in the URL anymore 🚀

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());
}

See the url_strategy package README or the explanation on StackOverflow for more detailed usage documentation.

Implementation

The package is basically a wrapper around the flutter_web_plugins setUrlStrategy. The reason it exists is that using the function from flutter_web_plugins requires conditional imports.
The problem is solved by using a conditional export from the url_strategy package.

Categories

Source repository

Projects using this package

No data available yet.