InternalStoragePathHandler class

Handler class to open files from application internal storage. For more information about android storage please refer to Android Developers Docs: Data and file storage overview.

To avoid leaking user or app data to the web, make sure to choose directory carefully, and assume any file under this directory could be accessed by any web page subject to same-origin rules.

Opens the requested file from the exposed data directory.

The matched prefix path used shouldn't be a prefix of a real web path. Thus, if the requested file cannot be found a WebResourceResponse object with a null data will be returned instead of null. This saves the time of falling back to network and trying to resolve a path that doesn't exist. A WebResourceResponse with null data will be received as an HTTP response with status code 404 and no body.

The MIME type for the file will be determined from the file's extension using guessContentTypeFromName. Developers should ensure that asset files are named using standard file extensions. If the file does not have a recognised extension, text/plain will be used by default.

Inheritance

Constructors

InternalStoragePathHandler({required String path, required String directory})
Handler class to open files from application internal storage. For more information about android storage please refer to Android Developers Docs: Data and file storage overview.
InternalStoragePathHandler.fromPlatform({required PlatformInternalStoragePathHandler platform})
Constructs a InternalStoragePathHandler from a specific platform implementation.
InternalStoragePathHandler.fromPlatformCreationParams({required PlatformInternalStoragePathHandlerCreationParams params})
Constructs a InternalStoragePathHandler.

Properties

directory String
no setter
eventHandler PlatformPathHandlerEvents?
Event handler object that handles the PlatformPathHandler events.
latefinalinherited
hashCode int
The hash code for this object.
no setterinherited
path String
The suffix path to be handled.
no setterinherited
platform PlatformInternalStoragePathHandler
Implementation of PlatformInternalStoragePathHandler for the current platform.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String
The path handler type.
no setterinherited

Methods

handle(String path) Future<WebResourceResponse?>
Handles the requested URL by returning the appropriate response.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
inherited
toMap() Map<String, dynamic>
inherited
toString() String
A string representation of this object.
inherited

Operators

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