Update version:A.B.C+X
in pubspec.yaml
.
For Android:
A.B.C
represents the versionName
such as 1.0.0
.
X
(the number after the +
) represents the versionCode
such as 1
, 2
, 3
, etc.
Do not forget to execute flutter build apk
or flutter run
after this step, because: When you run flutter build apk
or flutter run
after updating this version
in the pubspec
file, the versionName
and versionCode
in local.properties
are updated which are later picked up in the build.gradle (app)
when you build your flutter project using flutter build apk
or flutter run
which is ultimately responsible for setting the versionName
and versionCode
for the apk.
For iOS:
A.B.C
represents the CFBundleShortVersionString
such as 1.0.0
.
X
(the number after the +
) represents the CFBundleVersion
such as 1
, 2
, 3
, etc.
Do not forget to execute flutter build ipa
or flutter run
after this step
Figured this one out. Documentation is not straight forward
in your pubspec.yaml
change the version like this
version: 1.0.2+2
where the stuff is VER_NAME+
VER_CODE
Solution:
Inside pubspec.yaml add this (probably after description, same indentation as of description, name etc...):
version: 2.0.0+2
Then do packages get inside flutter local directory (Do not forget to do this)
Explanation:
Everything before plus is version name and after is version code. So here the version code is 2 and name is 2.0.0. Whenever you give an update to the flutter app make sure to change the version code compulsorily!
Addtional Info:
Whenever android app is built, build.gradle inside android/app/ looks for version code and name. This usually lies in local.properties which is changed every time you change flutter pubspec.yaml
The default version number of the app is 1.0.0. To update it, navigate to the pubspec.yaml
file and update the following line:
version: 1.0.0+1
Just change that version to (As per your need )
version: 1.0.1+2
The version number is three numbers separated by dots, such as 1.0.0 in the example above, followed by an optional build number such as 1 in the example above, separated by a +.
Both the version and the build number may be overridden in Flutter’s build by specifying --build-name and --build-number, respectively.
In Android, build-name is used as versionName while build-number used as versionCode. For more information, see Version your app
After updating the version number in the pubspec file
, run flutter pub
get from the top of the project, or use the Pub get button in your IDE. This updates the versionName
and versionCode
in the local.properties
file, which are later updated in the build.gradle
file when you rebuild the Flutter app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With