sg_cli 1.0.7 copy "sg_cli: ^1.0.7" to clipboard
sg_cli: ^1.0.7 copied to clipboard

CLI tool for rapidly generating code for Flutter projects with BLoC.

example/README.md

sg_cli example #

sg_cli isn't a library you import — it's a command-line tool. This page walks through a real session, from a blank Flutter project to a working screen with a custom BLoC event.

1. Install it once #

dart pub global activate sg_cli
export PATH="$PATH":"$HOME/.pub-cache/bin"

2. Scaffold the architecture #

Run this from the root of a Flutter project (next to pubspec.yaml):

cd my_flutter_app
sg init

sg init asks which architecture you want — pick Max for the full setup (BLoC, type-safe navigation, state handlers, 48+ widgets). It then copies the boilerplate into lib/, updates your pubspec.yaml, and writes a sg_cli.yaml like this:

version: max
route_paths:
  - lib/app/app_routes

Every command you run after this reads that file to know which version's generator to use — that's the whole point of SgConfig and getConfig() in this package.

3. Generate a screen #

sg create screen profile

This creates:

lib/presentation/screens/profile/
├── logic/
│   ├── profile_bloc.dart
│   ├── profile_event.dart
│   └── profile_state.dart
└── view/
    ├── profile_screen.dart
    └── widgets/

...and registers the route automatically, so Go.to(const ProfileRoute()) works immediately — no manual wiring.

4. Add a bottom sheet, a dialog, and an event #

sg create bs select_language
sg create dialog confirm_logout
sg create event load_profile in profile

The last command drops a new event class straight into profile_event.dart:

class LoadProfile extends ProfileEvent {
  const LoadProfile();

  @override
  Map<String, dynamic> getAnalyticParameters() => {};

  @override
  List<Object?> get props => [];
}

...with a matching handler stub already registered in profile_bloc.dart.

sg setup_flavors
sg setup_deeplink

setup_flavors wires up dev/stage/prod for both Android and iOS. setup_deeplink then asks for each flavor's domain and configures the Android manifest and iOS entitlements to match.

That's the full loop: sg init once, then sg create ... for every new screen, sheet, dialog, or event as your app grows.

4
likes
160
points
135
downloads

Documentation

API reference

Publisher

verified publishersolguruz.com

Weekly Downloads

CLI tool for rapidly generating code for Flutter projects with BLoC.

Homepage

License

Apache-2.0 (license)

Dependencies

args, package_config, pub_semver, web

More

Packages that depend on sg_cli