pubspec.lock文件需不需要忽略掉,主要看两种情况
- 如果我们开发的是普通的Flutter App,pubspec.lock需要加入到版本控制中。多人开发时,这样可以通过lockfile文件约束每个人依赖的三方库版本是一致的。
Application packages should check their lockfiles into source control, so that everyone working on the application and every location the application is deployed has a consistent set of dependencies. Because their dependencies are constrained by the lockfile, application packages usually specify any for their dependencies’ version constraints.
- 如果开发的是只是个Flutter Library,不需要将pubspec.lock加入到版本控制中。因为Library应该支持不同的依赖版本以确保兼容性。
Don’t check the lockfile of a library package into source control, since libraries should support a range of dependency versions. The version constraints of a library package’s immediate dependencies should be as wide as possible while still ensuring that the dependencies will be compatible with the versions that were tested against.
本文讨论了在Flutter项目开发中如何正确处理pubspec.lock文件。对于应用程序包而言,应当将其纳入版本控制以确保所有开发者的依赖版本一致;而对于库包,则应避免这样做以保持对多种依赖版本的支持。

被折叠的 条评论
为什么被折叠?



