FlutterRoute class
Route for serving Flutter web applications with WASM support.
Combines static file serving with automatic fallback to index.html for client-side routing, plus WASM headers (COOP/COEP) for multi-threading.
By default, critical Flutter files (index.html, flutter_service_worker.js, flutter_bootstrap.js, manifest.json, version.json) are served with no-cache headers to prevent stale app manifests and service workers. All other files can be cached according to browser heuristics or custom cache control.
To invalidate the cache, change the version in your pubspec.yaml file and build your Flutter project.
pod.webServer.addRoute(
FlutterRoute(Directory('web/flutter_app')),
);
- Inheritance
-
- Object
- HandlerObject
- Route
- FlutterRoute
Constructors
- FlutterRoute(Directory directory, {File? indexFile, CacheControlFactory cacheControlFactory = _defaultFlutterCacheControl, CacheBustingConfig? cacheBustingConfig})
- Creates a new FlutterRoute.
Properties
- asHandler → Handler
-
Returns this HandlerObject as a Handler.
no setterinherited
- cacheBustingConfig → CacheBustingConfig?
-
Cache busting configuration for static files
final
- cacheControlFactory → CacheControlFactory
-
Cache control factory for static files
final
- directory → Directory
-
The directory containing Flutter web files
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- indexFile → File
-
The index file to use as fallback (defaults to index.html in directory)
final
-
methods
→ Set<
Method> -
The methods this route will respond to, i.e. HTTP get or post.
finalinherited
- path → String
-
The suffix path this route will respond to.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
Request req) → Future< Result> -
Handles a call to this route, by extracting Session from request and
forwarding to handleCall.
inherited
-
handleCall(
Session session, Request request) → FutureOr< Result> -
Handles a call to this route.
override
-
injectIn(
RelicRouter router) → void -
Adds this handler to the given
routerwith Method.get and path '/' Override to add differently.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
noCacheFiles
→ const Set<
String> - Files that should never be cached to prevent issues with stale app manifests, service workers, or version mismatches.