package_info_plus 5.0.1 package_info_plus: ^5.0.1 copied to clipboard
Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android.
This Flutter plugin provides an API for querying information about an application package.
Platform Support #
You can use the PackageInfo to query information about the application package. This works both on iOS and Android.
import 'package:package_info_plus/package_info_plus.dart'; ... // Be sure to add this line if `PackageInfo.fromPlatform()` is called before runApp() WidgetsFlutterBinding.ensureInitialized(); ... PackageInfo packageInfo = await PackageInfo.fromPlatform(); String appName = packageInfo.appName; String packageName = packageInfo.packageName; String version = packageInfo.version; String buildNumber = packageInfo.buildNumber;
Known Issues #
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_plus on iOS requires the Xcode build folder to be rebuilt after changes to the version
pubspec.yaml. Clean the Xcode build folder with:
XCode Menu -> Product -> (Holding Option Key) Clean build folder.
Android (and potentially all platforms) #
PackageInfo.fromPlatform() before the
runApp() call will cause an exception.
I see wrong version on Windows platform
There was an issue in Flutter, which is already resolved since Flutter 3.3.
If your project was created before Flutter 3.3 you need to migrate the project according to [this guide] (https://docs.flutter.dev/release/breaking-changes/windows-version-information) first to get correct version with