Asset class abstract
π JetLeaf Framework - Represents a non-Dart static resource (e.g., HTML, CSS, images).
The compiler generates implementations of this class to expose metadata and raw content for embedded or served assets during runtime.
Represents a static asset (e.g., HTML, CSS, JS, images, or any binary file) that is bundled with the project but not written in Dart code.
This is typically used in frameworks like JetLeaf for handling:
- Static web resources (HTML templates, stylesheets)
- Server-rendered views
- Embedded images or configuration files
These assets are typically provided via compiler-generated implementations and may be embedded in memory or referenced via file paths.
Example
final asset = MyGeneratedAsset(); // implements Asset
print(asset.getFilePath()); // "resources/index.html"
print(utf8.decode(asset.getContentBytes())); // "<html>...</html>"
- Inheritance
-
- Object
- ResourceDeclaration
- Asset
- Implementers
- Available extensions
Constructors
Properties
- hashCode β int
-
The hash code for this object.
no setterinherited
- runtimeType β Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getContentAsString(
) β String -
Available on Asset, provided by the AssetExtension extension
Extension methods for Asset objects. -
getContentBytes(
) β Uint8List -
Returns the binary content of the asset (same as
_contentBytes
). -
getFileName(
) β String -
Returns the name of the file (same as
_fileName
). -
getFilePath(
) β String -
Returns the full path to the file (same as
_filePath
). -
getPackageName(
) β String? -
Returns the name of the originating package (same as
_packageName
). -
getUniqueName(
) β String - Returns a unique name for the asset, combining the package name and file name.
-
noSuchMethod(
Invocation invocation) β dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) β Map< String, Object> -
Serializes this resource to a JSON-encodable map.
override
-
toString(
) β String -
Standard string representation of this resource.
inherited
Operators
-
operator ==(
Object other) β bool -
The equality operator.
inherited