Dynamic App Version Number

Here is how you can automatically get and show the version number of your app.

  1. Create the following custom action, and don't forget to add package_info_plus: ^4.2.0 to Pubspec Dependencies.

    import 'package:package_info_plus/package_info_plus.dart';
    
    Future<String> getVersionNumber() async {
      PackageInfo packageInfo = await PackageInfo.fromPlatform();
      String versionNumber = packageInfo.version;
      return versionNumber;
    }
  1. On the page displaying the version number, call the getVersionNumber custom action and use the output; e.g., you can write the output into a page state variable.

34
6 replies