DART语言:如何获取所有可以导入的课程?
从程序上,我想获取所有可用的DART文件以导入。 我该如何实现这一目标? (以编程方式)
Programmatically I want to get all dart files available to import.
How can I achievement this? (programmatically)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要哪个环境?
如果是一个单个酒吧软件包,请确保已运行
dart pub get
,然后解析.dart_tool/Package_config.json
文件并找到所有软件包的根。然后浏览这些目录的所有dart
不是部分文件的文件(不以...; 的一部分开头)。其余的应该是可以导入的DART库文件。如果您只需要从
lib/
内导入的软件包,则可能要解析pubspec.yaml
文件,因此您可以忽略dev_dependenciesies
。然后,您可能还需要列出可用的
飞镖:...
平台库。哪些可用取决于您编译的平台。您需要以某种方式弄清楚这一点,然后您应该只保留每个平台的列表。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 alldart
files that are not part files (does not start withpart 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 thepubspec.yaml
file too, so you can ignore thedev_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.