π 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.dartlike:
// 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