Using Package Info Plus
You can use the PackageInfo to query information about the application package. This works both on iOS and Android.
// Be sure to add this line if `PackageInfo.fromPlatform()` is called before runApp()
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String appName = packageInfo.appName;
String packageName = packageInfo.packageName;
String version = packageInfo.version;
String buildNumber = packageInfo.buildNumber;
Plugin returns incorrect app version
Flutter build tools allow only digits and
. (dot) symbols to be used in
pubspec.yaml on iOS/MacOS to comply with official version format from Apple.
More info available in this comment
I have changed version in pubspec.yaml and plugin returns wrong info
As noted on issue 20761, package_info on iOS
requires the Xcode build folder to be rebuilt after changes to the version string in
Clean the Xcode build folder with:
XCode Menu -> Product -> (Holding Option Key) Clean build folder.
Plugin returns package version in
buildNumber when no build number specified in pubspec.yaml
Plugin doesn't modify the output of iOS. In this case
buildNumber in the plugin is CFBundleVersion in iOS. This property returns version when build number is not specified.buildNumber
See CFBundleVersion docs for more inf.
Android (and potentially all platforms)
PackageInfo.fromPlatform() before the
runApp() call will cause an exception.