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.yaml gains a workspace: list entry for the plugin's relative path.
  • Plugin pubspec.yaml gains resolution: workspace at 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 targetDir looking for the nearest ancestor pubspec.yaml that contains a top-level flutter: key.
enrollWorkspace({required String parentPubspecPath, required String pluginRelativePath, required String pluginPubspecPath}) Future<void>
Enrolls the plugin at pluginRelativePath into the Dart pub workspace declared in the parent pubspec.yaml at parentPubspecPath.
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