Plugin Icon if
  • Code Tools

FlutterAssetsGenerator

43 загрузки
Обновлено:
2 месяца назад
Версия:

3.1.0

Обзор
Версии

Обзор

A powerful Android Studio / IntelliJ plugin that automatically generates a type-safe, hierarchical asset index for your Flutter projects.

Support

  • Found a bug or unexpected behavior? Please report it at GitHub Issues.
  • New plugin releases are published at GitHub Releases. Check there for the latest release notes and installable packages.

Core Features

  • Hierarchical Generation: Generates classes that mirror your directory structure (e.g., Assets.images.logo).
  • Multi-Module Support: Seamlessly supports nested Flutter modules and monorepos (e.g. example/ or packages/).
  • Legacy Compatibility: Supports style: legacy to generate flat variable names (e.g. Assets.imagesLogo) for easy migration.
  • Smart Type Support: Automatically detects SVG, Lottie and Rive files.
  • Widget Integration: Generates .svg(), .lottie() and .rive() methods directly on asset objects.
  • Auto Dependency Management: Automatically checks and adds flutter_svg, lottie or rive dependencies.
  • YAML as Source of Truth: In 3.x, behavior is driven by pubspec.yaml. Modules without flutter_assets_generator config are not watched or generated automatically.
  • Disable Cleanup: Setting enable: false stops generation for that module and removes the previously generated Dart file.
  • Smart Auto Update:
    • Assets: Watch for image additions/deletions and regenerate automatically.
    • Config: Triggered on File Save (Cmd+S) in pubspec.yaml. Smart diffing ensures builds only run when necessary.
    • Performance: Setup and generation run asynchronously, and generated-file formatting is skipped to keep EDT writes minimal. In the 2026-04-21 monorepo reproduction, batch generation dropped from 23.7s to 1.512s (15.67x faster, 93.6% lower total time), while average per-module write time dropped from 1339.88ms to 7.62ms (175.72x faster, 99.4% lower).

Usage

1. Quick Setup (Recommended)

For first-time users, use the one-click setup:

  • Menu: Click Tools -> Flutter Assets Generator -> Setup Project Configuration.
  • Project View: Right-click the root directory of a Flutter module, then click Flutter: Setup Current Module to configure only that module.

Project activation and module setup follow these rules:

  • The plugin treats a project as available when it can find at least one valid Flutter module in the current workspace.
  • A valid Flutter module must be rooted at its own pubspec.yaml directory and contain Flutter configuration (flutter: or Flutter SDK dependency).
  • Temporary generated directories such as .dart_tool, build, .symlinks, .plugin_symlinks, and ephemeral are excluded from module detection.
  • The Project View setup entry is shown only when the selected directory exactly matches a Flutter module root. Child folders such as lib/ or assets/ do not show the entry.
  • package_parameter_enabled defaults to false for Flutter apps and add-to-app Flutter modules, and defaults to true for other Flutter packages.
  • Both project-level setup and current-module setup use the same automatic defaults.

This will automatically add the default configuration to your pubspec.yaml:

flutter_assets_generator: enable: true output_dir: generated/ output_filename: assets class_name: Assets auto_detection: true auto_add_dependencies: true style: robust # Options: robust (default), legacy (legacy) leaf_type: class # Options: class (default for robust), string (default for legacy) name_style: camel # Options: camel (default), snake package_parameter_enabled: false # Flutter packages default to true path_ignore: []

2. Manual Configuration (Optional)

flutter_assets_generator: # Enable/Disable this plugin for the current module. Default: true when the block exists enable: true # When set to false, generation stops and the previous generated Dart file is removed # Sets the directory of generated files. Default: generated/ output_dir: generated/ # Sets the name for the generated file. Default: assets output_filename: assets # Enable package parameter generation (package: 'your_package_name'). Default: false package_parameter_enabled: false # Sets the name for the root class. Default: Assets class_name: Assets # Enable/Disable auto monitoring and dependency management. Default: true auto_detection: true # Add dependencies to pubspec.yaml automatically. Default: true auto_add_dependencies: true # Generation style: robust (Hierarchical) or legacy (Flat legacy). Default: robust style: robust # Leaf type: class (typed wrappers) or string (raw asset path). Default: class for robust, string for legacy leaf_type: class # Name style for generated identifiers. Default: camel name_style: camel # For legacy style: Prefix variable names with parent directory names. Default: true named_with_parent: true # Ignore specific paths. Default: [] path_ignore: ["assets/fonts"]

When leaf_type: string, asset references return raw String paths (e.g., Assets.icons.user returns a string). In this mode the plugin will not auto-add flutter_svg, lottie, or rive.

When style: legacy and leaf_type: class, the generator keeps flat access paths but wraps known asset types with typed helpers:

// legacy + leaf_type: classstatic const AssetGenImage imagesLogo = AssetGenImage('assets/images/logo.png');static const SvgGenImage iconsHome = SvgGenImage('assets/icons/home.svg');// Unknown types (e.g. mp4, json) still fall back to Stringstatic const String videosIntro = 'assets/videos/intro.mp4';

Modules without a flutter_assets_generator block are not monitored automatically. If you run Generate Assets before initialization, the plugin will ask you to run Setup Project Configuration first.

3. Generate File

  • Menu: Click Tools -> Flutter Assets Generator -> Generate Assets.
  • Shortcut: Press Option(Mac) / Alt(Win) + G.
  • Generated File Writes: Generated Dart files are written directly without an additional IDE reformat pass, reducing EDT stalls in large monorepos.

4. Access Assets in Code

The plugin generates a strict, type-safe hierarchy:

// Standard ImageAssets.images.logo.image(width: 24, height: 24);// SVG (Requires flutter_svg dependency)Assets.icons.home.svg(color: Colors.blue);// Lottie (Requires lottie dependency)Assets.anim.loading.lottie(repeat: true);// Rive (Requires rive dependency)Assets.anims.input.rive(fit: BoxFit.contain);// Custom widget builder - allows you to build any widget with the asset pathAssets.images.logo.custom( builder: (context, assetPath) { return YourCustomWidget(assetPath: assetPath); },); // Get raw path stringString path = Assets.images.logo.path;

Версии

Версия
Диапазон совместимости
Дата обновления
2026
3.1.0
203.0+
28.02.2026
Скачать
3.0.0
203.0 — 253.*
08.02.2026
Скачать
2023
2.4.2
203+
23.02.2023
Скачать
Plugin ID:
com.crzsc.FlutterAssetsGenerator
icon