If you are working on an application package, then you should keep the pubspec . lock file in your repository as a snapshot of your dependencies.
Read moreWhat does Pubspec lock do?
Regenerating the pubspec. lock file lets you test your package against the latest compatible versions of its dependencies .
Read more