PathUrlStrategy class

Uses the browser URL's pathname to represent Flutter's route name.

In order to use PathUrlStrategy for an app, it needs to be set like this:

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

void main() {
  // Somewhere before calling `runApp()` do:
  setUrlStrategy(PathUrlStrategy());
}
Inheritance

Constructors

PathUrlStrategy([PlatformLocation platformLocation = const BrowserPlatformLocation(), bool includeHash = false])
Creates an instance of PathUrlStrategy.

Properties

hashCode int
The hash code for this object.
no setterinherited
includeHash bool
There were an issue with url #hash which disappears from URL on first start of the web application This flag allows to preserve that hash and was introduced mainly to preserve backward compatibility with existing applications that rely on a full match on the path. If someone navigates to /profile or /profile#foo, they both will work without this flag otherwise /profile#foo won't match with the /profile route name anymore because the hash became part of the path.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addPopStateListener(PopStateListener fn) VoidCallback
Adds a listener to the popstate event and returns a function that, when invoked, removes the listener.
inherited
getPath() String
Returns the active path in the browser.
override
getState() Object?
The state of the current browser history entry.
inherited
go(int count) Future<void>
Moves forwards or backwards through the history stack.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prepareExternalUrl(String internalUrl) String
Given a path that's internal to the app, create the external url that will be used in the browser.
override
pushState(Object? state, String title, String url) → void
Push a new history entry.
inherited
replaceState(Object? state, String title, String url) → void
Replace the currently active history entry.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited