Get Version - Get the Version Name, Version Code, Platform and OS Version, and App ID on iOS and Android. Maintainer: @rodydavis

Overview

Flutter Community: get_version

Buy Me A Coffee Donate github pages

get_version

alt text

Online Demo: https://fluttercommunity.github.io/get_version/

Description

Get the Version Name, Version Code and App ID on iOS and Android.

Setup

Android

Go to build.gradle and update:

defaultConfig {
  versionCode 1
  versionName "1.0"
  minSdkVersion 16
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

iOS

Already good to go.

How to Use

Get OS Version:

String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
  platformVersion = await GetVersion.platformVersion;
} on PlatformException {
  platformVersion = 'Failed to get platform version.';
}

Get Version Name:

String projectVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
  projectVersion = await GetVersion.projectVersion;
} on PlatformException {
  projectVersion = 'Failed to get project version.';
}

Get Version Code:

String projectCode;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
  projectCode = await GetVersion.projectCode;
} on PlatformException {
  projectCode = 'Failed to get build number.';
}

Get App ID:

String projectAppID;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
  projectAppID = await GetVersion.appID;
} on PlatformException {
  projectAppID = 'Failed to get app ID.';
}

Get App Name:

String projectName;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
  projectName = await GetVersion.appName;
} on PlatformException {
  projectName = 'Failed to get app name.';
}

Example

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get_version/get_version.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _projectVersion = '';
  String _projectCode = '';
  String _projectAppID = '';
  String _projectName = '';

  @override
  initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await GetVersion.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    String projectVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      projectVersion = await GetVersion.projectVersion;
    } on PlatformException {
      projectVersion = 'Failed to get project version.';
    }

    String projectCode;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      projectCode = await GetVersion.projectCode;
    } on PlatformException {
      projectCode = 'Failed to get build number.';
    }

    String projectAppID;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      projectAppID = await GetVersion.appID;
    } on PlatformException {
      projectAppID = 'Failed to get app ID.';
    }
    
    String projectName;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      projectName = await GetVersion.appName;
    } on PlatformException {
      projectName = 'Failed to get app name.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
      _projectVersion = projectVersion;
      _projectCode = projectCode;
      _projectAppID = projectAppID;
      _projectName = projectName;
    });
  }

  

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        ),
        body: new SingleChildScrollView(
          child: new ListBody(
            children: <Widget>[
              new Container(
                height: 10.0,
              ),
              new ListTile(
                leading: new Icon(Icons.info),
                title: const Text('Name'),
                subtitle: new Text(_projectName),
              ),
              new Container(
                height: 10.0,
              ),
              new ListTile(
                leading: new Icon(Icons.info),
                title: const Text('Running on'),
                subtitle: new Text(_platformVersion),
              ),
              new Divider(
                height: 20.0,
              ),
               new ListTile(
                leading: new Icon(Icons.info),
                title: const Text('Version Name'),
                subtitle: new Text(_projectVersion),
              ),
              new Divider(
                height: 20.0,
              ),
              new ListTile(
                leading: new Icon(Icons.info),
                title: const Text('Version Code'),
                subtitle: new Text(_projectCode),
              ),
              new Divider(
                height: 20.0,
              ),
              new ListTile(
                leading: new Icon(Icons.info),
                title: const Text('App ID'),
                subtitle: new Text(_projectAppID),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
Comments
  • Android MissingPluginException

    Android MissingPluginException

    MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/package_info)
    E/flutter (31899): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
    E/flutter (31899): MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/package_info)
    E/flutter (31899): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7)
    E/flutter (31899): <asynchronous suspension>
    E/flutter (31899): #1      PackageInfo.fromPlatform (package:package_info/package_info.dart:35:17)
    E/flutter (31899): <asynchronous suspension>
    E/flutter (31899): #2      GetVersion.projectCode (package:get_version/get_version.dart:22:49)
    E/flutter (31899): <asynchronous suspension>
    E/flutter (31899): #3      AdministratorMiddleware.call (package:swz_android_vms/redux/middleware/admin_middleware.dart:52:41)
    E/flutter (31899): <asynchronous suspension>
    E/flutter (31899): #4      Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
    E/flutter (31899): #5      RegisterMiddleware.call (package:swz_android_vms/redux/middleware/register_middleware.dart:72:9)
    E/flutter (31899): <asynchronous suspension>
    E/flutter (31899): #6      Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
    E/flutter (31899): #7      Store.dispatch (package:redux/src/store.dart:250:20)
    E/flutter (31899): #8      _SettingScreenState._handleBuildOnceCompleted (package:swz_android_vms/screen/setting_screen.dart:333:12)
    E/flutter (31899): <asynchronous suspension>
    E/flutter (31899): #9      _SettingScreenState.build.<anonymous closure> (package:swz_android_vms/screen/setting_screen.dart:75:9)
    E/flutter (31899): #10     _StoreStreamListenerState._init.<anonymous closure> (package:flutter_redux/flutter_redux.dart)
    E/flutter (31899): #11     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
    E/flutter (31899): #12     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:938:9)
    E/flutter (31899): #13     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
    E/flutter (31899): #14     _invoke (dart:ui/hooks.dart:128:13)
    E/flutter (31899): #15     _drawFrame (dart:ui/hooks.dart:117:3)
    

    Library Version: ^0.0.6 Flutter 0.7.3 • channel beta • https://github.com/flutter/flutter.git Framework • revision 3b309bda07 (10 days ago) • 2018-08-28 12:39:24 -0700 Engine • revision af42b6dc95 Tools • Dart 2.1.0-dev.1.0.flutter-ccb16f7282

    bug 
    opened by wheel1992 5
  • Error on iOS emulator (12.0) with SWIFT_VERSION mismatch ...

    Error on iOS emulator (12.0) with SWIFT_VERSION mismatch ...

    When I am running in debug mode on an IOS emulator -- it won't build because of the following error..

    Not sure how to fix :(

    === BUILD TARGET get_version OF PROJECT Pods WITH CONFIGURATION Debug ===

           Check dependencies
           The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. Supported values are: 3.0, 4.0, 4.2. This setting can be set inthe build settings editor.
    

    [ +6 ms] Could not build the application for the simulator. [ +2 ms] Error launching application on iPhone X. [ +3 ms] "flutter run" took 6,431ms.

    opened by sjmcdowall 1
  • [dart_lsc] Prepare for 1.0.0 version of sensors and package_info

    [dart_lsc] Prepare for 1.0.0 version of sensors and package_info

    This should be a safe change, for more details see: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0

    This change was auto generated by dart_lsc.

    opened by amirh 0
  • After upgrading flutter to 2.10.0 stable channel dont allow to create build

    After upgrading flutter to 2.10.0 stable channel dont allow to create build

    import 'package:package_info/package_info.dart';
           ^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:4:8: Error: Error when reading '/C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.3+4/lib/package_info.dart': The system cannot find the path specified.
    
    import 'package:package_info/package_info.dart';
           ^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:15:11: Error: 'PackageInfo' isn't a type.
        final PackageInfo packageInfo = await PackageInfo.fromPlatform();
              ^^^^^^^^^^^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:15:43: Error: Undefined name 'PackageInfo'.
        final PackageInfo packageInfo = await PackageInfo.fromPlatform();
                                              ^^^^^^^^^^^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:21:11: Error: 'PackageInfo' isn't a type.
        final PackageInfo packageInfo = await PackageInfo.fromPlatform();
              ^^^^^^^^^^^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:21:43: Error: Undefined name 'PackageInfo'.
        final PackageInfo packageInfo = await PackageInfo.fromPlatform();
                                              ^^^^^^^^^^^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:27:11: Error: 'PackageInfo' isn't a type.
        final PackageInfo packageInfo = await PackageInfo.fromPlatform();
              ^^^^^^^^^^^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:27:43: Error: Undefined name 'PackageInfo'.
        final PackageInfo packageInfo = await PackageInfo.fromPlatform();
                                              ^^^^^^^^^^^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:33:11: Error: 'PackageInfo' isn't a type.
        final PackageInfo packageInfo = await PackageInfo.fromPlatform();
              ^^^^^^^^^^^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/get_version-0.2.2/lib/get_version.dart:33:43: Error: Undefined name 'PackageInfo'.
        final PackageInfo packageInfo = await PackageInfo.fromPlatform();
                                              ^^^^^^^^^^^
    /C:/Users/Paresh/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/platform-3.0.0/lib/src/interface/local_platform.dart:46:19: Error: Member not found: 'packageRoot'.
          io.Platform.packageRoot; // ignore: deprecated_member_use
                      ^^^^^^^^^^^
    
    
    FAILURE: Build failed with an exception.
    
    
    opened by Pareshoct7 0
  • Android V2 embedding

    Android V2 embedding

    Below warning is been shown, when setting up get_version.

    The plugin get_version uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

    opened by wishstore36 4
  • Build error on IOS - Unable to determine Swift version

    Build error on IOS - Unable to determine Swift version

    Hi, I get the following build error on IOS:

    [!] Unable to determine Swift version for the following pods:

    - `get_version` does not specify a Swift version and none of the targets (`Runner`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
    

    Please help!

    opened by mikthemonster 0
  • Swift compatibility

    Swift compatibility

    I get this issue, when i ran the project

    Xcode's output:
    ↳
        === BUILD TARGET connectivity OF PROJECT Pods WITH CONFIGURATION Debug ===
        /Users/Nikesh/.pub-cache/hosted/pub.dartlang.org/get_version-0.1.0/ios/Classes/GetVersionPlugin.m:2:9: fatal error: 'get_version/get_version-Swift.h' file not found
        #import <get_version/get_version-Swift.h>
    
    bug help wanted 
    opened by nikekannan 3
Owner
Flutter Community
A central place for all community made Flutter packages. To get started, see the README of the 'community' repository.
Flutter Community
The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.

The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs. Inspired by SwiftGen. Motivation Using asset path str

FlutterGen 1.1k Jan 6, 2023
Official Git of flutter code-push made by Chimera inc. If you want to get more info or seek for biz corporation, you can contact [email protected].

中文版 Chimera Flutter Code Push Chimera is a Dart compiler developed by ourselves, which generates interpretable and executable bytecode to implement co

Waytoon 21 Oct 6, 2022
VS Code `.code-workspace` file generator

VS Code .code-workspace file generator (for monorepositories with Dart and Flutter projects) TL;DR; Create yaml file config.yaml (check #Format sectio

Mike T 1 Feb 18, 2022
Flutter get Android meta-data in AndroidManifest.xml

Flutter get Android meta-data in AndroidManifest.xml

周枇杷! 1 Mar 9, 2022
A tool to easily install the Android SDK command-line and platform tools.

gibadb A tool to easily install the Android SDK command-line and platform tools. For developers: This README describes the CLI tool that ships with th

null 3 Sep 22, 2022
Log snapshot management solution (iOS/Android/Web/Server) built with Flutter/Dart using Bloc pattern and Firebase Firestore backend.

Log snapshot management solution (iOS/Android/Web/Server) built with Flutter/Dart using Bloc pattern and Firebase Firestore backend.

Alexey Perov 5 Nov 9, 2022
BMI Calculator is a Mobile Application for Android and iOS built by Flutter

BMI Calculator ?? Our Goal The objective of this tutorial is to look at how we can customise Flutter Widgets to achieve our own beautiful user interfa

Fady Fawzy 2 Jan 10, 2022
Pensil Teaching App is an education platform created in flutter.

Pensil Teaching App Pensil Teach App is an education platform created specifically for the tutors of the digital age. Pensil Teaching app reduce gap b

Pensil Inc 45 Dec 1, 2022
UME is an in-app debug kits platform for Flutter. Produced by Flutter Infra team of ByteDance

flutter_ume English Flutter 应用内调试工具平台 当前版本内置 10 个插件, 开发者可以创建自己的插件,并集成进 UME 平台。 详见本文为 UME 开发插件部分。 flutter_ume 快速接入 特别说明 功能介绍 为 UME 开发插件 版本说明 兼容性 单测覆盖率

Bytedance Inc. 1.8k Dec 30, 2022
Integrate easily the Paygate Global Platform into your Flutter app

Integrate easily the Paygate Global Platform into your Flutter app Features Implement payment with the Paygate Global Platform. Support for two paymen

Kokou AGBAVON 7 Dec 15, 2022
Chuanying - what you see is what you get. 传影--所见即所得

传影--所见即所得 简介 从前 想要制作证件照,需要先把图片用QQ传到电脑,再用PS手动抠图; 看到一句喜欢的话,想要记到电脑里,需要一个字一个字用键盘打出来; 看到黑板上老师写的公式,想要记到Word里,需要用MathType一点点打出来; 但是有没有可能,只用手机拍照,就能搞定上面所有的事,一步

null 16 Apr 8, 2022
A mobile map based application to help people everywhere around the world get help

Wonder This is a mobile application made by flutter. The application is called "Wonder" because it will help people everywhere around the world to get

Sara Nersisian 1 Dec 2, 2021
Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations between routers

UPROOT Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations be

GeekVisit 73 Jan 1, 2023
A comprehensive, cross-platform path manipulation library for Dart.

A comprehensive, cross-platform path manipulation library for Dart. The path package provides common operations for manipulating paths: joining, split

Dart 159 Dec 29, 2022
Easy to use cross-platform regex replace command line util

replace Easy to use cross-platform regex replace command line util. Can't remember the arguments to the find command? or how xargs works? Maybe sed is

Rob Becker 3 Feb 1, 2022
Flutter Version Management: A simple CLI to manage Flutter SDK versions.

fvm Flutter Version Management: A simple cli to manage Flutter SDK versions. FVM helps with the need for a consistent app builds by allowing to refere

Leo Farias 3.2k Jan 8, 2023
Dart language version of Persian-Tools

Persian tools Persian Tools dart package which you can use in all platforms Features Adding ordinal suffixes Converting Persian words to number Conver

Persian Tools 54 Dec 29, 2022
Command-line tool to provide null-safety percentage info of a project. Track your migration progress on mixed-version programs that execute with unsound null safety.

null_safety_percentage Command-line tool to provide null-safety percentage info of a project. Track your migration progress on mixed-version programs

dartside.dev 8 Mar 27, 2022
Starter project and code generator for Flutter/Redux

Flutter Redux Starter/Code Generator Videos Short video ~ 1 minute Long video ~ 10 minutes We're using this approach to develop the Flutter app for In

Hillel Coren 278 Dec 12, 2022