libraries property Null safety

Map<Uri, LibraryMirror> libraries
inherited

Returns a map of all libraries in the current isolate.

Implementation

@override
Map<Uri, LibraryMirror> get libraries {
  ReflectorData reflectorData = data[this]!;
  if (reflectorData.libraryMirrors == null) {
    throw NoSuchCapabilityError('Using `libraries` without capability. '
        'Try adding `libraryCapability`.');
  }
  Map<Uri, LibraryMirror> result = <Uri, LibraryMirror>{};
  for (LibraryMirror library in reflectorData.libraryMirrors!) {
    result[library.uri] = library;
  }
  return UnmodifiableMapView(result);
}