Table of Contents
What is the version format in Flutter?
Today, our topic is how do I manage the version of the Flutter App and what is caret operator. We are learning pubspec.yaml and covered its basics in the last class. Now, we will conclude it. Version is a required field in pubspec.yaml. Every software and application has a version, for example, 3.0.0. In pubspec.yaml file, the default version is as under:
version: 1.0.0+1
How to I change the version of an app?
We can change the version of an app in the following three parts:
- Major Version
- Minor Version
- Patch Version
Major Version
The first digit of the version is referred to major version. For example, in 3.0.0 ‘3’ is the major version. It changes in sequence like 3,4,5,6 due to major changes. It is important to note that it rarely changes.
Minor Version
The second part of the version is referred to as a minor version. For example, in 4.1.3, ‘1’ is a minor version. It changes in sequence like 2,3,4,5 and due to minor amendments like changes in the design of an app.
Patch Version
The last part of the version is referred to patch version. For example, in 4.1.3 ‘3’ is a patch version and it changes due to bug fixing or a little bit of changing in an app. In most cases, the patch version changes rather than the minor or major version.
How do I change the app version on Flutter iOS?
We do not need to necessarily app version on Flutter Android or iOS in sequence like the first patch number, minor, and then major version. It wholly depends upon the nature of change. May we need to change the major or minor version directly instead of doing changes in the patch?
Version Code
In a version like 1.0.0+1, ‘+1’ is a version code or build no. It shows how many times we have changed/ updated the app. It doesn’t refer to specific major, minor, or patch version changes but depends upon any kind of change. It changes like +1, +2, +3, etc.
Version Suffix
We can also use different version suffixes while developing an app like alpha, beta, and rc with app version. Alpha means our app is in development mode like 1.0.0-alpha. Beta means it is in testing mode like 1.0.0.-beta and RC means release canning i.e. it is in the pro testing phase like 1.0.0-rc. After passing these version suffixes, our first stable version is termed 1.0.0+1.
Environment
In pubspec.yaml, dart version is set as minimum ‘>= 2.19.4 <3.0.0’. It means that any plugin, external library, etc must be in this range. Otherwise, a compatibility issue arises. For example, if we intend to use a plugin that was developed before the 2.19.4 Dart version, we cannot use it. It is pertinent to mention here that on some occasions, we need to change this minimum version to complete our task for the time being. Hopefully now we can answer the question how do I manage the version of the Flutter App.
Dependencies
It is one of the most important parts of pubspec.yaml. Our project depends on different packages which are added here. Our package initially depends on sdk Flutter and Cupertino_icons, we will find both here. Similarly, plugin detail is also available here.
Dev dependencies
It is the same as dependencies. When we are in development mode, our related packages can be seen here. After completion of the development mode, we can shift them to dependencies.
Flutter
Fonts, images, icons, video/ audio files, and configuration of Flutter apps are under Flutter in pubspec.yaml. Activity: Check versions of different apps, games on Play Store on following link:
https://play.google.com/store/apps?hl=en&gl=US
Caret Operator
A lot of versions of plugins in dependencies are with caret operators like the cupertino_icons version. It is to ensure backward compatibility and non-breaking updates. It is used to work with all minor and patch updates under the same major version. The example of the caret operator is ^2.3.6 >=2.3.6 <3.0.0.
Where is the ^ symbol on the PC keyboard?
The caret operator ^ symbol on the PC keyboard is on 6. When we press Shift+6 caret operator appears.
What is the caret symbol in versioning?
It is used to define range which means all versions before the major version will work. For example, after uploading our app on Play Store Flutter introduces new minor or patch changes. If we don’t use the caret operator then it will stop working due to compatibility issues. But if we use the caret operator, it will work till the Major version changes. It is germane to mention here that Major changes do not occur suddenly. It takes considerable time and we can use that function till that time.