Flutter: package_info.version is always "1.0"

2,911

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:

https://github.com/fluttercommunity/plus_plugins/blob/main/packages/package_info_plus/package_info_plus/lib/package_info_plus.dart#L47

Share:
2,911
Scriptim
Author by

Scriptim

Updated on December 07, 2022

Comments

  • Scriptim
    Scriptim over 1 year

    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.

  • Bishoy Hanna
    Bishoy Hanna about 5 years
    if its set as.... <key>CFBundleShortVersionString</key<string>$(FLUTTER_BUILD_‌​NAME)</string>.... I'm having the same problem too.
  • Daniel Sogbey
    Daniel Sogbey about 2 years
    @Bishoy Hanna Yeah same as me even the versionName in app/build.grades is flutterVersionName
  • Shailendra Madda
    Shailendra Madda about 2 years
    Any update on this? and the links provided are not found
  • diegoveloper
    diegoveloper about 2 years
    @ShailendraMadda answer updated