πŸš€ F S A β€’ Flutter Smart Assets

FSA (Flutter Smart Assets) is a lightweight CLI tool that automatically scans your Flutter project's assets directories, then:

βœ… Updates your pubspec.yaml with proper indentation
βœ… Generates a strongly-typed app_assets.dart file
βœ… Uses UPPERCASE constants with format suffixes intact (e.g. LOGO_PNG)
βœ… Includes summary comments at the top of generated files


πŸ“¦ Installation

dart pub global activate fsa

Make sure the global bin is in your PATH.


⚑ Usage

fsa generate

This will:

  • Scan all files in assets/
  • Update pubspec.yaml β†’ flutter: assets: (with 2-space indentation)
  • Generate lib/app_assets.dart like:
// GENERATED CODE - DO NOT MODIFY BY HAND
// Generated by fsa (Flutter Smart Assets) - safe mode
// Assets: 6 files | Images: 1 | Fonts: 3 | Lottie: 2

class AppAssets {
  static const LOGO_PNG = "assets/logo.png";
  static const ICON_SVG = "assets/icon.svg";
}

class AppOthers {
  static const CONFIG_JSON = "assets/config.json";
}

πŸ”§ Example Workflow

fsa generate
# βœ… Assets scanned
# βœ… pubspec.yaml updated
# βœ… app_assets.dart created

Frequently Asked Questions (FAQ)

❓ Why do I get `command not found: fsa` after installation?

When you run:

dart pub global activate fsa

Dart installs the fsa executable into a global bin directory. However, your terminal can only run it if that directory is added to your PATH.


βœ… How do I add Dart’s global bin to PATH?

macOS / Linux

Add this line to your shell config file (~/.zshrc, ~/.bashrc, etc.):

export PATH="$PATH":"$HOME/.pub-cache/bin"

Then reload your terminal:

source ~/.zshrc   # or ~/.bashrc

Windows (PowerShell)

Run:

setx PATH "$env:PATH;C:\\Users\\<YourUser>\\AppData\\Local\\Pub\\Cache\\bin"

Then restart your terminal.


❓ How do I upgrade to the latest version of fsa?

If you already installed fsa before and want to upgrade to the latest published version, just run:

dart pub global activate fsa

Dart will automatically detect if there’s a newer version and reinstall it.

If you want to force a clean reinstall, do:

dart pub global deactivate fsa
dart pub global activate fsa

πŸ“œ License

BSD 3-clause license


Author: Ayoigbala Soares β€” https://github.com/hermes13002

Libraries

fsa