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:

  1. Validate the snake_case name argument.
  2. Resolve the target directory (--path > --target > default <projectRoot>/packages/<name>/).
  3. Spawn flutter create --template=package via FlutterCreateRunner to lay down the baseline Dart package (pubspec, LICENSE, CHANGELOG, .gitignore, .metadata, lib/<name>.dart, test/<name>_test.dart, README, analysis_options).
  4. Compute the dynamic artisanPath (and magicPath in magic mode) and render the generic scaffold stubs from assets/stubs/make_plugin/generic/, overwriting flutter create's pubspec.yaml, lib/<name>.dart, test/<name>_test.dart, and README.md with our versions.
  5. 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.
  6. Detect a parent Flutter app via WorkspaceEnroller; when found, enroll the plugin into the parent's pub workspace (adds resolution: workspace to the plugin pubspec and a workspace: list entry to the parent pubspec).
  7. 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 the magic_ / fluttersdk_ convention prefix stripped (e.g. magic_logger → logger). Drives the default <commandPrefix>:install / <commandPrefix>:uninstall names.
  • bootstrapCommand, the value of the --bootstrap-command option, or <commandPrefix>:install when the option is absent.
  • artisanPath, the dynamically computed relative path from the target directory to the fluttersdk_artisan package root. Replaces the old hardcoded path: ../../ that broke for non-standard target depths.
  • magicPath, the dynamically computed relative path from the target to the magic package 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

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 list next to name).
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
name → String
Dispatch key. Colons (:) act as namespace prefixes for artisan list grouping (e.g. dusk:snap groups under dusk).
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 true when 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_artisan package root. Used by ArtisanPathResolver to compute the dynamic artisanPath placeholder 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 magic package 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