简体   繁体   English

如何管理 flutter 中的 dart 包

[英]how to manage dart packages in flutter

I created a package A and B我创建了一个 package A 和 B
in package A , i add shared_preferences: 0.5.12 to pubspec.yaml在 package A中,我将shared_preferences: 0.5.12添加到 pubspec.yaml
in package B , i add shared_preferences: 0.5.10 to pubspec.yaml在 package B中,我将shared_preferences: 0.5.10添加到 pubspec.yaml
is this correct or i should use the same package version in different packages?这是正确的还是我应该在不同的包中使用相同的 package 版本? if YES, how can i guarantee the dependencies of the other libraries from pub.dev using the same version.如果是,我如何保证来自 pub.dev 的其他库的依赖关系使用相同的版本。

When i create myApp, i will add package A and B in myApp, should I also add shared_preferences to myApp?(yes).当我创建 myApp 时,我将在 myApp 中添加 package A 和 B,我是否也应该将 shared_preferences 添加到 myApp 中?(是的)。
Can someone explain how to share pacages or use packages across different packages?有人可以解释如何在不同的包之间共享包或使用包吗?

Your package version should look like:您的 package 版本应如下所示:

some_package: ^1.2.1

where 1.2.1 is what you tested.其中1.2.1是您测试的。 This lets pub pick any version 1.2.1 or greater, up to just before 2.0.0, which should be the first breaking interface change.这让 pub 可以选择任何 1.2.1 或更高版本,直到 2.0.0 之前的版本,这应该是第一个破坏性接口更改。

See https://semver.org for the meaning of the numbers, and https://dart.dev/tools/pub/versioning#semantic-versions for the specifics about the pubspec.yaml.有关数字的含义,请参见https://semver.org 有关 pubspec.Z6EEDC03A68A69933C27F 的详细信息,请参见 https://dart.dev/tools/pub/versioning#semantic-versions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM