Programmatically I want to get all dart files available to import. How can I achievement this? (programmatically)
CodePudding user response:
In which environment do you want that?
If it's for a single Pub package, ensure that dart pub get
has been run, then parse the .dart_tool/package_config.json
file and find the roots of all the packages. Then search through those directories for all dart
files that are not part files (does not start with part of ...;
). The rest should be Dart library files which can be imported.
If you only want the packages that can be imported from inside lib/
, you may want to parse the pubspec.yaml
file too, so you can ignore the dev_dependencies
.
Then you may also want to list the available dart:...
platform libraries. Which are available depends on which platform you compile for. You need to figure that out somehow, then you should just keep a list for each platform.