2

Say if this is my pubspec.yaml

name: my_pub
description: My Pub
version: 0.0.1
publish_to: none

How do I get the version name/number of my_pub inside that package. Is there any way to get it?

Or should I store it as a const inside lib? In that how do i make sure both the verison name (in pubspec and inside package) be in sync.

Harsh Bhikadia
  • 10,095
  • 9
  • 49
  • 70
  • i want to do some feature toggling based on version number inside the package – Harsh Bhikadia Apr 19 '19 at 05:26
  • Possible duplicate of [How to get build and version number of Flutter app](https://stackoverflow.com/questions/53672171/how-to-get-build-and-version-number-of-flutter-app) – ishaan Apr 19 '19 at 08:16
  • The post you suggested is for flutter app only, i want for any dart packagr – Harsh Bhikadia Apr 19 '19 at 08:20
  • In that case you can directly parse the YAML file if possible. Also, if you're looking for a dart only solution, remove the flutter tag. This might be helpful: https://stackoverflow.com/questions/23613279/access-to-pubspec-yaml-attributes-version-from-dart-app – ishaan Apr 19 '19 at 08:32
  • the question sugegsted should work with flutter as well? – Harsh Bhikadia Apr 19 '19 at 10:39
  • i want it work for both flutter and other dart SDKs – Harsh Bhikadia Apr 19 '19 at 10:40

0 Answers0