Search code examples
dartdart-mirrors

How to get a list of all loaded libraries in dart?


Is it possible to make some call from main to get all the loaded libraries at runtime?

main(){
  Iterable<LibraryMirror> libraries = getAllLoadedLibraries();
}

I see there is a Type LibraryMirror in the mirrors package but I don't see how you would get a library mirror since you can't just reference them in code like a top level function/variable or class name.


Solution

  • import 'dart:mirrors`;
    
    currentMirrorSystem().libraries;