MakePluginCommand class
artisan make:plugin <name>, scaffolds a new fluttersdk_artisan plugin
skeleton under packages/<name>/ (or a --target / --path override).
Pipeline
The handler runs in eight phases:
- Validate the snake_case name argument.
- Resolve the target directory (
--path>--target> default<projectRoot>/packages/<name>/). - Spawn
flutter create --template=packageviaFlutterCreateRunnerto lay down the baseline Dart package (pubspec, LICENSE, CHANGELOG,.gitignore,.metadata,lib/<name>.dart,test/<name>_test.dart, README, analysis_options). - Compute the dynamic
artisanPath(andmagicPathin magic mode) and render the generic scaffold stubs fromassets/stubs/make_plugin/generic/, overwritingflutter create's pubspec.yaml,lib/<name>.dart,test/<name>_test.dart, andREADME.mdwith our versions. - When isMagic is true: render the magic-add-on stubs from
assets/stubs/make_plugin/magic/(install.yaml, install_command, uninstall_command, config_stub, install_command_test) AND replace the generic pubspec with the magic-flavored one that includes the magic dependency. - Detect a parent Flutter app via WorkspaceEnroller; when found, enroll
the plugin into the parent's pub workspace (adds
resolution: workspaceto the plugin pubspec and aworkspace:list entry to the parent pubspec). - Print the success banner + next-steps hint, including whether the parent app's pubspec.yaml was modified.
Replacement variables
Every stub uses these placeholders, derived once from the name argument and the resolved paths:
name, the snake_case package name (e.g.magic_logger).pascalName, the PascalCase class root (e.g.MagicLogger).commandPrefix, the package name with themagic_/fluttersdk_convention prefix stripped (e.g.magic_logger→logger). Drives the default<commandPrefix>:install/<commandPrefix>:uninstallnames.bootstrapCommand, the value of the--bootstrap-commandoption, or<commandPrefix>:installwhen the option is absent.artisanPath, the dynamically computed relative path from the target directory to thefluttersdk_artisanpackage root. Replaces the old hardcodedpath: ../../that broke for non-standard target depths.magicPath, the dynamically computed relative path from the target to themagicpackage root. Only set in magic mode; absent in generic mode so the generic pubspec stub never references magic.
Test injection
Three seams support deterministic tests:
- resolveArtisanRoot / resolveMagicRoot / resolveStubDir —
override in test subclasses to pin the package roots without touching
Isolate.resolvePackageUri. FlutterCreateRunner— pass a stub via the constructor to skip the real subprocess spawn.- WorkspaceEnroller — pass an in-memory variant via the constructor to assert workspace enrollment without touching real pubspec files.
- Inheritance
-
- Object
- ArtisanCommand
- MakePluginCommand
Constructors
- MakePluginCommand({FlutterCreateRunner? flutterCreateRunner, WorkspaceEnroller? workspaceEnroller})
- Public default constructor. Optional injection seams default to real implementations.
Properties
- boot → CommandBoot
-
What boot context the dispatcher must establish before calling handle.
See CommandBoot for the V1 taxonomy (none, connected).
no setteroverride
- description → String
-
One-line description (rendered in
artisan listnext to name).no setteroverride - hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Dispatch key. Colons (
:) act as namespace prefixes forartisan listgrouping (e.g.dusk:snapgroups underdusk).no setterinherited - parsedSignature → CommandSignature?
-
Lazy-parsed signature. Cached for the lifetime of the instance.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- signature → String
-
Optional Laravel-style signature DSL. When set, name derives from
it and configure auto-registers the declared options/flags.
no setteroverride
Methods
-
configure(
ArgParser parser) → void -
Auto-applies signature to the parser when set. Override to register
extra ArgParser features (mandatory options, aliases, custom value
validators). When you override, call
super.configure(parser)first if you also use the signature DSL.inherited -
handle(
ArtisanContext ctx) → Future< int> -
Execute the command. Returns the process exit code.
override
-
isMagic(
ArtisanContext ctx) → bool -
Returns
truewhen magic-aware scaffolding should be applied. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolveArtisanRoot(
) → Future< String> -
Resolves the absolute path of the
fluttersdk_artisanpackage root. Used byArtisanPathResolverto compute the dynamicartisanPathplaceholder and by resolveStubDir to locate the stub bundle. -
resolvedPath(
ArtisanContext ctx) → String? - Resolves the target directory from the operator-supplied flags.
-
resolveMagicRoot(
) → Future< String> -
Resolves the absolute path of the
magicpackage root. -
resolveStubDir(
) → Future< String> -
Resolves the directory holding the
make_plugin/stub bundle. Tests can override either this method directly or resolveArtisanRoot to pin the bundle location. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited