How to Get the App Version/Build Number in Flutter
Here's how you can get and display the version number of your Flutter app.
I was building an About page in my Flutter app today and was wondering how to get and display the app version number. A couple google searches and Flutter reloads later, I found out how to do it using the package_info plugin. Here's how.
Add the package_info package to your Flutter project by listing the former as a dependency in your pubspec.yaml as below. Protip, use Pubspec Assist to speed this up.
2. Import package_info in the file where you'll be needing the version file.
3. Write an async function that will return the version number (or whatever else you need; you can get the build number, your app name, or package name):
4. As the version number will be loaded asynchronously, use a FutureBuilder together with a Text widget (or any other widget of your choice):
5. In my case, I wrapped the text in a disabled ListTile, so that I could place it inside a settings page. Full Example:
That's it! Your page will look somewhat like this:
Thanks for reading. If you have any questions, drop them below. Hope this helped!
You might also like...
Browser Extensions I Can't Live Without
A list of browser extensions that took minutes to add, but made my browsing experience immeasurably better.
3 min read
How to Track Daily Steps (Implementing a Pedometer) in Flutter
Recently, I was trying to add a daily steps tracker in one of the apps I was working on. It wasn't easy, so I wrote down how I did it.
5 min read
Implementing Instagram's Basic Display API in Flutter
A simple & thorough guide on how to get a user's info using Instagram's Basic Display API in Flutter.
7 min read
We built an app (that works) to end the crisis quicker in 🇲🇺. Now we need your help to deliver it to you.
I feel like a failure as I write this (long) post, but I’m still doing it, because I believe
5 min read
Adding (Anonymous) Comments to Your Ghost Blog Using Commento for Free
Add anonymous, beautifully designed comments to your Ghost blog for free using Commento