gpt4 book ai didi

dart - 如何在 Dart 中获取脚本路径?

转载 作者:行者123 更新时间:2023-12-04 15:23:07 39 4
gpt4 key购买 nike

我需要找出 Dart 脚本(当前正在运行)所在的目录。我该怎么做?

以前,这可以通过 new Options().script 实现,但该类(class)已不复存在。来自 main(args) 的参数列表没有帮助,因为它只包含参数,而不是执行的 Dart 文件(至少在 Mac OS X 上)。

最佳答案

根据 BREAKING CHANGE: dart:io Platform and Options are deprecated, and will be removedBreaking Change: Platform.script is a Uri, dart:platform library is gone new Options().script应替换为 Platform.script .

请注意 Platform.script返回 Uri你应该考虑使用 toFilePath从文件 URI 中获取文件路径。

关于dart - 如何在 Dart 中获取脚本路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19906391/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com