FlutterRoute constructor
FlutterRoute(
- Directory directory, {
- File? indexFile,
- CacheControlFactory cacheControlFactory = _defaultFlutterCacheControl,
- CacheBustingConfig? cacheBustingConfig,
- String? host,
Creates a new FlutterRoute.
The directory parameter specifies the root directory containing Flutter
web files. The indexFile parameter sets the fallback file for SPA
routing and defaults to index.html within the specified directory.
Cache behavior can be customized using cacheControlFactory for static
asset headers and cacheBustingConfig for cache busting support. If no
cacheControlFactory is provided, a default factory is used that prevents
caching of critical Flutter files (index.html, flutter_service_worker.js,
flutter_bootstrap.js, manifest.json, version.json) while allowing other
files to be cached according to browser heuristics.
The host parameter restricts this route to a specific virtual host
(defaults to null, matching any host).
Implementation
FlutterRoute(
this.directory, {
File? indexFile,
this.cacheControlFactory = _defaultFlutterCacheControl,
this.cacheBustingConfig,
super.host,
}) : indexFile = indexFile ?? File(path.join(directory.path, 'index.html')),
super(methods: {Method.get, Method.head});