Package constructor

Package(
  1. String name,
  2. Uri root, {
  3. Uri? packageUriRoot,
  4. LanguageVersion? languageVersion,
  5. Object? extraData,
  6. bool relativeRoot = true,
})

Creates a package with the provided properties.

The name must be a valid package name. The root must be an absolute directory URI, meaning an absolute URI with no query or fragment path and a path starting and ending with /. The packageUriRoot, if provided, must be either an absolute directory URI or a relative URI reference which is then resolved relative to root. It must then also be a subdirectory of root, or the same directory, and must end with /. If languageVersion is supplied, it must be a valid Dart language version, which means two decimal integer literals separated by a ., where the integer literals have no leading zeros unless they are a single zero digit.

The relativeRoot controls whether the root is written as relative to the package_config.json file when the package configuration is written to a file. It defaults to being relative.

If extraData is supplied, it will be available as the Package.extraData of the created package.

Implementation

factory Package(String name, Uri root,
        {Uri? packageUriRoot,
        LanguageVersion? languageVersion,
        Object? extraData,
        bool relativeRoot = true}) =>
    SimplePackage.validate(name, root, packageUriRoot, languageVersion,
        extraData, relativeRoot, throwError)!;