Skip to content
Back to archipelago.banuacoder.com

UI, Assets & L10N

flutter_asset Free ​

Tier
Freeversion 1.2.5
Command
archipelago generate flutter_asset
Generates
  • packages/asset_core
  • packages/<app_name>_asset

A Mason brick for generating type-safe asset packages with pure Dart contracts (asset_core) and Flutter asset enums with real SVG icons and Lottie animations.

Variables ​

VariableTypeDefaultDescription
appNamestringMyAppApplication name for package naming
prefixstringAppPrefix for asset class names
isForMonorepobooleantrueWhether this package will be part of a monorepo structure
includeGeneratedbooleanfalseWhether to include generated files in version control

Usage ​

Interactive ​

bash
archipelago generate flutter_asset

Non-interactive (CI) ​

bash
archipelago generate flutter_asset --config my_config.json

Config Template ​

json
{
  "@appName": "Application name for package naming",
  "appName": "MyApp",
  "@prefix": "Prefix for asset class names",
  "prefix": "App",
  "@isForMonorepo": "Whether this package will be part of a monorepo structure",
  "isForMonorepo": true,
  "@includeGenerated": "Whether to include generated files in version control",
  "includeGenerated": false
}

Generated Structure ​

text
packages/
├── asset_core/
│   ├── lib/
│   │   ├── asset_core.dart                # Barrel file
│   │   └── src/
│   │       ├── {prefix}_asset.dart
│   │       ├── {prefix}_asset_category.dart
│   │       ├── {prefix}_asset_data.dart
│   │       ├── {prefix}_asset_type.dart
│   │       └── contracts/
│   │           ├── contracts.dart
│   │           ├── {prefix}_animation_asset.dart
│   │           ├── {prefix}_icon_asset.dart
│   │           ├── {prefix}_illustration_asset.dart
│   │           └── {prefix}_logo_asset.dart
│   ├── analysis_options.yaml
│   └── pubspec.yaml
└── {app_name}_asset/
    ├── lib/
    │   ├── {app_name}_asset.dart          # Barrel file
    │   └── src/
    │       └── generated/
    │           ├── generated.dart
    │           ├── animations.dart
    │           ├── logos.dart
    │           └── icons/
    │               ├── icons.dart
    │               ├── actions_icons.dart
    │               ├── arrows_icons.dart
    │               ├── communication_icons.dart
    │               ├── essentials_icons.dart
    │               ├── feedback_icons.dart
    │               ├── files_icons.dart
    │               ├── finance_icons.dart
    │               ├── maps_icons.dart
    │               ├── media_icons.dart
    │               ├── security_icons.dart
    │               ├── time_icons.dart
    │               └── users_icons.dart
    ├── assets/
    │   ├── icons/                         # SVG icons by category
    │   │   ├── actions/
    │   │   ├── arrows/
    │   │   ├── communication/
    │   │   ├── essentials/
    │   │   ├── feedback/
    │   │   ├── files/
    │   │   ├── finance/
    │   │   ├── maps/
    │   │   ├── media/
    │   │   ├── security/
    │   │   ├── time/
    │   │   └── users/
    │   ├── animations/                    # Lottie animations (.json or .lottie)
    │   └── logos/                         # Logo assets
    ├── analysis_options.yaml
    ├── asset_generator.yaml               # Since 1.1.0 — see below
    └── pubspec.yaml

API ​

asset_core is a pure-Dart contracts package — no Flutter dependency. Every generated asset is a type-safe enum implementing one of its contracts:

dart
abstract interface class AppAsset {
  AppAssetData get data;
  String get defaultSemanticLabel;
}

abstract interface class AppIconAsset implements AppAsset {
  static const double sizeSmall = 16.0;
  static const double sizeMedium = 24.0;
  static const double sizeLarge = 32.0;
  static const category = AppAssetCategory.icon;
}
// AppAnimationAsset, AppIllustrationAsset, AppLogoAsset follow the same shape.

Generated icons are per-category enums implementing AppIconAsset, one enum value per SVG file:

dart
// {app_name}_asset/lib/src/generated/icons/actions_icons.dart
enum AppActionsIcons(this.filename) implements AppIconAsset {
  copy('copy.svg'),
  download('download.svg'),
  search('search.svg'),
  settings('settings.svg'),
  // ...
}

Since 1.2.1, the pre-baked files match a fresh asset_generator 1.2.1 run: each enum uses a primary constructor, and only enums with a _dark variant (here logos.dart) carry a _darkFilename field. See asset_generator for both shapes. The public API is unchanged.

flutter_ui_kit's AssetWidget/{prefix}AssetExtension render any AppAsset value directly — the asset package itself has no rendering code (that's asset_core's pure-Dart split: contracts here, Flutter rendering in the UI kit).

Asset Generator Config ​

Since 1.1.0, the generated package ships asset_generator.yaml, templated with this package's real assets_path: assets, output_path: lib/src/generated, prefix, package_name, and the 12 real icon subcategory directories — so the separate asset_generator devtool brick (dart run monorepo_toolkit asset-gen generate) can rediscover and regenerate this exact structure with the correct prefix, instead of silently falling back to CLI defaults.

Dependencies ​

  • asset_core has no Flutter dependency — pure Dart contracts only.
  • Since 1.2.0, {Prefix}AssetType.lottie.extensions is ['.json', '.lottie'] and {Prefix}AssetTypeExtension.fromPath maps .lottie (dotLottie zip) paths to {Prefix}AssetType.lottie. The lottie package renders both formats, so no widget change is needed.
  • The generated {app_name}_asset package depends on asset_core (path) and ships the SVG/Lottie assets themselves; no external pub packages are required to hold the type-safe references (rendering libraries like flutter_svg/lottie live in flutter_ui_kit, not here).
  • No self-generation and no hard dependency on another brick.

Known Limitations ​

  • No native platform setup — pure Dart/Flutter assets.
  • Regenerating assets from source SVGs/Lottie files (e.g. after adding new icons) requires the separate asset_generator brick; this brick only produces the initial, pre-baked snapshot.

Changelog ​

Run archipelago brick info flutter_asset to see the latest published version. Enterprise customers can read the full CHANGELOG.md in the brick source repository.