Reputation: 1832
I'm trying to get my Flutter app's version using the package_info plugin.
import 'package:package_info/package_info.dart';
// ...
PackageInfo.fromPlatform().then((pkgInfo) {
print(pkgInfo.version); // prints "1.0"
});
However, in pubspec.yaml
, I specified version: 2.0.0
.
Where does the plugin get the version numer from? How can I change it?
Incidentally, pkgInfo.appName
matches the name
field in pubspec.yaml
.
Upvotes: 5
Views: 4938
Reputation: 103541
It's not the version from pubspec.yaml, it's the version from Android / iOS platform. So you should change the version in :
Android
android/app/build.gradle
file
versionCode 5
versionName "1.0"
iOS
ios/Runner/Info.plist
file
<key>CFBundleShortVersionString</key>
<string>1.0</string>
UPDATE
package_info
is deprecated, use package_info_plus instead.
For more information you can check how the native package get the version for each platform:
Upvotes: 1
Reputation: 99
This package_info on iOS requires the Xcode build folder to be rebuilt after changes to the version string in pubspec.yaml. Clean the Xcode build folder with: XCode Menu -> Product -> (Holding Option Key) Clean build folder.
Upvotes: 0