FileAsset class
A representation of a file-based resource.
Provides a uniform interface for accessing and manipulating files regardless of their source or location. Each asset has a unique id, a shortUri for reference, and a complete uri for direct access.
This implementation is backed by a File in the filesystem.
- Implemented types
Constructors
- FileAsset.new({required File file, required Uri shortUri, required String id})
- Creates a new FileAsset.
-
FileAsset.fromJson(Map<
String, dynamic> json) -
Creates a new FileAsset from a JSON representation.
factory
Properties
- file → File
-
The underlying file that this asset represents.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
A unique identifier for this asset.
it's typically a hash of the asset's shortUri.
final
- packageName → String?
-
Extracts the package name from the shortUri.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shortUri → Uri
-
A shortened URI that may use package or asset schemes.
final
- uri → Uri
-
The complete URI that points to this asset.
no setteroverride
Methods
-
existsSync(
) → bool -
Checks whether the asset exists.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readAsBytesSync(
) → Uint8List -
Reads the entire asset synchronously as a list of bytes.
override
-
readAsStringSync(
{Encoding encoding = utf8}) → String -
Reads the entire asset synchronously as a string.
override
-
safeDelete(
) → void -
Safely deletes the asset if it exists.
override
-
toJson(
) → Map< String, dynamic> -
Converts this asset to a JSON representation.
override
-
toString(
) → String -
A string representation of this object.
override
-
uriWithExtension(
String ext) → Uri -
Creates a new URI with the same path as this asset but with a different extension.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override