flutter_asset_gen library
Fast, configurable Dart/Flutter asset constants generator.
This library provides tools to automatically generate strongly-typed constants for your Flutter assets, with support for watch mode, enum output, pubspec validation, and build_runner integration.
Quick Start
import 'package:flutter_asset_gen/flutter_asset_gen.dart';
// Load configuration and generate assets
final config = loadConfig();
final result = await generateAssets(config: config);
Features
- Watch Mode: Automatically regenerate on file changes
- Enum Output: Generate enum-based asset constants
- Pubspec Validation: Validate against pubspec.yaml
- Build Runner: Full build_runner integration
- Flexible Configuration: Extensive customization options
Classes
- AssetGenBuilder
- Build runner builder for asset generation.
- AssetGenConfig
- Configuration for asset generation.
- AssetWatcher
- Watches asset directories for changes and automatically regenerates assets.
- GenerationResult
- Result of asset generation process.
- PubspecValidator
- Validates assets against pubspec.yaml configuration.
- ValidationResult
- Result of asset validation against pubspec.yaml.
Functions
-
assetGenBuilder(
BuilderOptions options) → Builder - Creates a new AssetGenBuilder instance.
-
generateAssets(
{AssetGenConfig? config, String? configPath, bool dryRun = false, bool verbose = false}) → Future< GenerationResult> - Generates asset constants from the specified configuration.
-
loadConfig(
[String? path]) → AssetGenConfig - Loads configuration from a YAML file.