addLibraries method

  1. @override
void addLibraries(
  1. List<LibraryDeclaration> libraries, {
  2. bool replace = false,
})
override

A mutable context used to collect and assemble metadata during the framework’s initialization or AOT compilation phase.

This interface is used internally to register discovered libraries, packages, assets, environment variables, and special types before the context is finalized via build.

The finalized output will be an immutable RuntimeProvider that provides a stable view of all application metadata.

Example

final context = StandardRuntimeProvider();
// Assuming you have a way to create ReflectedLibrary instances
context.addLibrary(myReflectedLibrary);
context.addPackage(myPackage);
context.addAsset(myAsset);
context.addSpecialType(mySpecialType);
context.addLibraries([lib1, lib2], replace: true);
context.addPackages([pkg1, pkg2], replace: true);
context.addAssets([asset1, asset2], replace: true);
context.addSpecialTypes([type1, type2], replace: true);

Adds a list of LibraryDeclarations to the context.

If replace is true, the existing library list will be cleared first.

context.addLibraries([lib1, lib2], replace: true);

Implementation

@override
void addLibraries(List<LibraryDeclaration> libraries, {bool replace = false}) {
  if (replace) {
    _libraries.clear();
  }
  _libraries.addAll(libraries);
}