Asset constructor
const
Asset({})
🍃 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>"
Implementation
const Asset({
required String filePath,
required String fileName,
required String packageName,
required Uint8List contentBytes,
}) : _filePath = filePath, _fileName = fileName, _packageName = packageName, _contentBytes = contentBytes;