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 (defaults to 'lib/'), a relative path resolved against the file URI of the rootPath. The result must be inside the rootPath.

The languageVersion specifies the package's Dart language version, in the form of 'X.Y', such as '3.9'.

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,
    ),
  );
}