AssetGenerator class
A utility class for automatically generating Dart code for assets.
This class scans an assets directory and generates a Dart file with strongly-typed asset references organized by folder structure.
Constructors
- AssetGenerator({String assetsDirectory = 'assets', String outputFile = 'lib/generated/assets.dart', String className = 'Assets', bool ignoreHiddenFiles = true, bool ignoreEnvFiles = true})
-
Creates an AssetGenerator with the specified configuration.
const
Properties
- assetsDirectory → String
-
The directory containing the assets to scan.
final
- className → String
-
The name of the main class to generate (default: 'Assets').
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- ignoreEnvFiles → bool
-
Whether to ignore environment files (files containing '.env').
final
- ignoreHiddenFiles → bool
-
Whether to ignore hidden files (files starting with '.').
final
- outputFile → String
-
The output file path where the generated code will be written.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
generate(
) → bool - Generates the assets Dart file from the assets directory.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited