parseString static method

PackageConfig parseString(
  1. String configuration,
  2. Uri baseUri, {
  3. void onError(
    1. Object error
    )?,
})

Parses a package configuration file.

The configuration must be a JSON object containing a valid package configuration.

The baseUri is used as the base for resolving relative URI references in the configuration file. If the configuration has been read from a file, the baseUri can be the URI of that file, or of the directory it occurs in.

If onError is provided, errors found during parsing or building the configuration are reported by calling onError instead of throwing, and parser makes a best effort attempt to continue despite the error. The input must still be valid JSON. The result may be PackageConfig.empty if there is no way to extract useful information from the bytes.

Implementation

static PackageConfig parseString(String configuration, Uri baseUri,
        {void Function(Object error)? onError}) =>
    parsePackageConfigString(configuration, baseUri, onError ?? throwError);