package_info_plus 9.0.1 copy "package_info_plus: ^9.0.1" to clipboard
package_info_plus: ^9.0.1 copied to clipboard

Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android.

package_info_plus #

package_info_plus pub points pub package

This Flutter plugin provides an API for querying information about an application package.

Platform Support #

Android iOS macOS Web Linux Windows

Requirements #

  • Flutter >=3.19.0
  • Dart >=3.3.0 <4.0.0
  • iOS >=12.0
  • macOS >=10.14
  • Java 17
  • Kotlin 2.2.0
  • Android Gradle Plugin >=8.12.1
  • Gradle wrapper >=8.13

Usage #

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;

Installer Store #

The installerStore property indicates which app store installed the application. This is useful for directing users to the appropriate store page for ratings or updates.

PackageInfo packageInfo = await PackageInfo.fromPlatform();
String? installerStore = packageInfo.installerStore;

iOS

On iOS, the installerStore value is determined by checking the app store receipt path:

Environment installerStore value
App Store com.apple
TestFlight com.apple.testflight
Simulator com.apple.simulator

Android

On Android, the value is the package name of the app store that installed the application, obtained via PackageManager.getInstallSourceInfo() (Android 11+) or PackageManager.getInstallerPackageName() (older versions).

Store installerStore value
Google Play Store com.android.vending
Amazon Appstore com.amazon.venezia
Samsung Galaxy Store com.sec.android.app.samsungapps
Huawei AppGallery com.huawei.appmarket
Xiaomi GetApps com.xiaomi.mipicks
OPPO App Market com.oppo.market
VIVO App Store com.vivo.appstore
Manual/ADB install null

Note: Some stores may not properly implement the installer package name API, which could result in null being returned even for store installations.

Other Platforms

On MacOS, Linux, Windows, and Web, installerStore returns null.

Known Issues #

iOS #

Plugin returns incorrect app version

Flutter build tools allow only digits and . (dot) symbols to be used in version of 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 string in pubspec.yaml. Clean the Xcode build folder with: XCode Menu -> Product -> (Holding Option Key) Clean build folder.

Android (and potentially all platforms) #

Calling to PackageInfo.fromPlatform() before the runApp() call will cause an exception. See https://github.com/fluttercommunity/plus_plugins/issues/309

Windows #

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 first to get correct version with package_info_plus

Web #

In a web environment, the package uses the version.json file that it is generated in the build process.

Accessing the version.json

The package tries to locate the version.json using three methods:

  1. Using the provided baseUrl in the fromPlatform() method.
  2. Checking the configured assets folder in the Flutter web configuration.
  3. Checking the path where the application is installed.

See the documentation at the method fromPlatform() to learn more.

CORS version.json access

It could be possible that the plugin cannot access the version.json file because the server is preventing it. This can be due a CORS issue, and it is known to happen when hosting the Flutter code on Firebase Hosting. Ensure that your CORS Firebase configuration allows it.

Learn more #

2.76k
likes
140
points
3.29M
downloads

Documentation

API reference

Publisher

verified publisherfluttercommunity.dev

Weekly Downloads

Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#information #identifier #utils

License

BSD-3-Clause (license)

Dependencies

clock, ffi, flutter, flutter_web_plugins, http, meta, package_info_plus_platform_interface, path, web, win32

More

Packages that depend on package_info_plus

Packages that implement package_info_plus