import method

(Importer, Stylesheet)? import(
  1. Uri url, {
  2. Importer? baseImporter,
  3. Uri? baseUrl,
  4. bool forImport = false,
})

Tries to import url using one of this cache's importers.

If baseImporter is non-null, this first tries to use baseImporter to import url (resolved relative to baseUrl if it's passed).

If any importers can import url, returns that importer as well as the parsed stylesheet. Otherwise, returns null.

Caches the result of the import and uses cached results if possible.

Implementation

(Importer, Stylesheet)? import(Uri url,
    {Importer? baseImporter, Uri? baseUrl, bool forImport = false}) {
  if (canonicalize(url,
          baseImporter: baseImporter, baseUrl: baseUrl, forImport: forImport)
      case (var importer, var canonicalUrl, :var originalUrl)) {
    return importCanonical(importer, canonicalUrl, originalUrl: originalUrl)
        .andThen((stylesheet) => (importer, stylesheet));
  } else {
    return null;
  }
}