DART语言:如何获取所有可以导入的课程?

发布于 2025-02-13 12:13:21 字数 51 浏览 0 评论 0原文

从程序上,我想获取所有可用的DART文件以导入。 我该如何实现这一目标? (以编程方式)

Programmatically I want to get all dart files available to import.
How can I achievement this? (programmatically)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凯凯我们等你回来 2025-02-20 12:13:22

您想要哪个环境?

如果是一个单个酒吧软件包,请确保已运行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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文