add method

void add({
  1. required String name,
  2. required String rootPath,
  3. String packageUri = 'lib/',
  4. String? languageVersion,
})

The rootPath will be given to toUriStr of toContent to produce the corresponding file:// URI, normally a POSIX path.

The packageUri is optional, a URI reference, resolved against the file URI of the rootPath. The result must be inside the rootPath.

Implementation

void add({
  required String name,
  required String rootPath,
  String packageUri = 'lib/',
  String? languageVersion,
}) {
  if (_packages.any((e) => e.name == name)) {
    throw StateError('Already added: $name');
  }
  _packages.add(
    _PackageDescription(
      name: name,
      rootPath: rootPath,
      packageUri: packageUri,
      languageVersion: languageVersion,
    ),
  );
}