gpt4 book ai didi

dart - pubspec.yaml 中的配置标志如何工作?

转载 作者:IT老高 更新时间:2023-10-28 12:34:26 24 4
gpt4 key购买 nike

我正在学习 Flutter 和 Dart。我注意到pubspec.yaml 文件似乎不仅仅包含第三方库的依赖版本。例如。

# The following section is specific to Flutter.
flutter:
uses-material-design: true

我了解 Dart Pub Tool定义了 pubspec.yaml 的格式,看起来像 Flutter 这样的框架可以通过额外的设置来增强 pubspec.yaml,从而引发以下问题:

  • pubspec.yaml 是设计用于提供配置标志还是仅用于提供依赖项?
  • flutter 的方式是使用 pubspec.yaml 惯用的 Dart 还是唯一的?
  • pubspec.yaml 是仅由 pub 工具解析还是在运行时作为通用应用程序配置文件解析?
  • Flutter 是否为 pubspec.yaml 实现了自己的解析器,并使 uses-material-design: true 等设置在运行时可用?

最佳答案

Is pubspec.yaml designed to be used to provide configuration flags or only dependencies?

从历史上看,它还包含纯 Dart 项目中的build设置。例如用于编译为 JS 的设置,但已移出到 build.yaml。见 https://github.com/dart-lang/build/blob/master/build_config/README.md

Does the way flutter use pubspec.yaml idiomatic Dart or unique?

这是 Flutter 独有的。

Does Flutter implement it's own parser for pubspec.yaml and make settings like uses-material-design: true available at runtime?

是的。

这些设置是构建时设置,而不是运行时设置。


其实我觉得这个文件混淆了不同的用途是相当不幸的。在 Flutter 早期,特定于 Flutter 的设置在不同的文件中,但这也造成了一些困难(不知道细节 - 只在 GitHub 讨论中看到它)所以他们将它与 pubspec.yaml 合并>.

关于dart - pubspec.yaml 中的配置标志如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55768557/

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