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.