🚀 flu - Flutter Utility for Developers
A developer-friendly CLI utility tool for Dart & Flutter projects that helps you scaffold projects, manage assets, and generate models faster.
Table of Contents
Installation
From pub.flutter-io.cn
dart pub global activate flu
Commands
create Create and configure new Flutter project
asset Generates const references for your Flutter assets.
gen [WIP] A faster model generator
flu create
Create and configure a new Flutter project.
Usage
flu create
This will prompt you for configurations.
You can also pass these options as arguments to skip prompts and create the project directly.
Options
-h, --help Print this usage information.
-n, --name The name of the project
-d, --description The description of the project
--org The organization name
--flutter-version The Flutter version used in FVM
--platforms The platforms supported by this project
[android, ios, web, linux, macos, windows]
--[no-]melos Whether to use Melos for the project
--workspace-name Name used for pub workspace (root pubspec.yaml)
--initial-version Initial version of the project
--dependencies Dependencies of the project
--dev-dependencies Dev dependencies of the project
Example
flu create -n my_app --org com.example --platforms android,ios,web --flutter-version 3.22.1 --melos
flu asset
Generates const references for your Flutter assets.
Usage
flu asset [arguments]
Options
-w, --watch Watch for changes and re-generate the assets class.
-n, --class-name The name of the generated asset class.
(defaults to "Assets")
Example
flu asset -n MyAssets
To automatically regenerate assets on file changes:
flu asset --watch
flu gen
(WIP)
A blazing fast model generator built using Rust ⚡
Usage
flu gen [arguments]
Options
-p, --path Path to dart files (default: lib/**/*.dart)
Features
- Generate model classes with simple
// @flu
syntax and blazing-fast performance. - This supports field types like
int
,double
,bool
,String
,DateTime
,enum
,List
,dynamic
, and custom models withfromJson
/toJson
methods. - It will generate the model in a
.flu.dart
file with<constructor>
,fromJson
,toJson
,copyWith
,toString
,hashCode
and==
methods.
Example
// @flu
abstract class _User {
String get name;
int? get age;
}
void main() {
final user = User(name: 'John', age: 25);
print(user.toJson()); // { "name": "John", "age": 25 }
final copy = user.copyWith(age: 30);
print(copy.age); // 30
final parsed = User.fromJson({"name": "John", "age": 25});
print(parsed); // User(name: John, age: 25)
print(user == parsed); // true
}
Syntax
- Class must be annotated with
// @flu
- Must be an abstract class
- Name must start with underscore (
_
) - Fields must be getters with return types, no implementation
- You can add per-field options with
// @flu
above the getter
You can generate the
flu
class from JSON using the J2M model converter.
Field Options
Custom JSON Key
// @flu
abstract class _User {
// @flu key="first_name"
String get name;
}
Will generate JSON like:
{ "first_name": "John" }
Enum Support
// @flu
abstract class _User {
// @flu enum
Role get role;
}
enum Role { admin, user }
Serialization and deserialization will be handled for the enum Role
.
License
This project is licensed under the MIT License.
If you like this project, give it a ⭐ on GitHub!