WorkspaceEnroller class
Detects a parent Flutter application in the directory hierarchy and enrolls a plugin package into its Dart pub workspace.
Enrollment means two idempotent mutations:
- Parent
pubspec.yamlgains aworkspace:list entry for the plugin's relative path. - Plugin
pubspec.yamlgainsresolution: workspaceat the top level.
Both mutations use YamlEditor for safe structural YAML editing — no raw
string concatenation.
Usage
final enroller = WorkspaceEnroller(RealFs());
final parentPubspec = enroller.detectParentFlutterApp('/path/to/plugin');
if (parentPubspec != null) {
await enroller.enrollWorkspace(
parentPubspecPath: parentPubspec,
pluginRelativePath: 'plugins/my_plugin',
pluginPubspecPath: '/path/to/plugin/pubspec.yaml',
);
}
Constructors
- WorkspaceEnroller(VirtualFs _fs)
-
Creates a WorkspaceEnroller backed by
fs.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
detectParentFlutterApp(
String targetDir) → String? -
Walks up the directory tree from
targetDirlooking for the nearest ancestorpubspec.yamlthat contains a top-levelflutter:key. -
enrollWorkspace(
{required String parentPubspecPath, required String pluginRelativePath, required String pluginPubspecPath}) → Future< void> -
Enrolls the plugin at
pluginRelativePathinto the Dart pub workspace declared in the parentpubspec.yamlatparentPubspecPath. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited