flutter - 如何在 pubspec.yaml 中添加用户定义的变量以进行颤振?
问题描述
基本上我需要将版本和我的本地依赖项 URL 分配为用户定义的变量,并在路径或我希望的任何地方分配相同的值
像下面这样的例子
mydependancyPath : D:\mylocalDependancy
commonUtils:
path: mydependancyPath
1.请让我知道如何实现上述目标
2.是否可以将另一个YAML文件导入pubspec.yaml
在Android中我可以实现如下
dagger_version=2.8
"com.google.dagger:dagger:${dagger_version}"
解决方案
是否可以将另一个 YAML 文件导入 pubspec.yaml
上面的答案是否定的,这是不可能的,因为
pubspec.yaml
不支持进口。现在对于您的主要问题:您可以使用YAML Anchors 和 Aliases例如:
# this line has the path , and stored in varName for future use we use *varName mydependancyPath : &varNam D:\mylocalDependancy # this line has the version number , so we can use *vers as a key that holds the value 2.8 myversion : &vers 2.8 #!join is to concatinate path : !join [*varName, *vers]
这是一个更详细的资源,因为我不确定语法,但这应该有助于您寻找什么
推荐阅读
- angular - Angular 7 - 更改路由内单个组件的基本 URL
- java - 由于国家/地区限制,Firebase 身份验证的登录/注册屏幕崩溃
- apache-spark - 在 dataproc / gcp 中顺序执行多个 Spark 作业
- payment-gateway - AesCryptUtil 无法解析为 ccAvenue 支付网关中的类型
- php - Laravel 改为发送邮件,将其保存在 gmail 草稿中,并准备好点击发送按钮
- php - 不要在 WooCommerce 中显示通知的 Web 服务失败响应中保存订单
- c# - 如何在c#的文本文件中记录所有MSExcel事件
- git - 由于 Perl 冲突,无法在文件夹上初始化“git svn”
- spring - Feign ErrorDecoder 未被调用 - 如何配置 feign 以使用它?
- angular - 无法滚动html