package_info_plus

v9.0.1

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

Архив пакета: https://pubdev.letsnova.ru/api/archives/package_info_plus/9.0.1.tar.gz

Установкаdart pub add package_info_plus

README

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

История изменений

9.0.1

  • DOCS(package_info_plus): add installerStore values documentation (#3721). (0534cd2d)

9.0.0

Note: This release has breaking changes.

On Android plugin now requires the following:

  • Android Gradle Plugin >=8.12.1
  • Gradle wrapper >=8.13
  • Kotlin 2.2.0
  • DOCS(all): replace MacOS by macOS in package READMEs (#3658). (72b6234c)
  • BREAKING FEAT(package_info_plus): Change Android compile SDK, update Android build config (#3674). (78c2b742)

8.3.1

  • FIX(package_info_plus): incorrect install time on macOS when app sandbox disabled (#3638). (2cf9297b)

8.3.0

8.2.1

  • FIX(package_info_plus): convert installTime to String instead of DateTime to avoid serialization issues (#3464). (aa10ce75)
  • FIX(package_info_plus): fix macOS compilation warning (#3460). (6eec56c4)

8.2.0

8.1.4

  • DOCS(package_info_plus): doc ref links and unnecessary library names (#3433). (9275f622)

8.1.3

  • FIX(package_info_plus): Resolve compilation issues with SPM enabled (#3406). (d421ec0e)

8.1.2

  • REFACTOR(all): Use range of flutter_lints for broader compatibility (#3371). (8a303add)
  • FIX(package_info_plus): add support for file scheme on web (#3345). (2d69758d)

8.1.1

  • FIX(package_info_plus): Update privacy manifest path (#3348). (f47fcc97)

8.1.0

  • FEAT(package_info_plus): Add Swift Package Manager support (#3171). (a14d4727)

8.0.3

8.0.2

  • CHORE(package_info_plus): Update to package:web to ">=0.5.0 <2.0.0" (#3102). (05f8afb8)
  • DOCS(package_info_plus): Update plugin requirements in README (#3163). (6f09bb7e)

8.0.1

  • FIX(package_info_plus): Address changed fields nullability on Android 15 (API 35) (#2975). (dfa3bc2d)
  • REFACTOR(all): Remove website files, configs, mentions (#3018). (ecc57146)
  • FIX(all): changed homepage url in pubspec.yaml (#3099). (66613656)

8.0.0

Note: This release has breaking changes.

  • DOCS(package_info_plus): Add platform specific documentation (#2845). (ad06a236)
  • DOCS(package_info_plus): Improve web documentation re. CORS (#2841). (7d712ef8)
  • BREAKING FEAT(package_info_plus): Switch to SHA-256 for buildSignature on Android (#2835). (7259af20)

7.0.0

Note: This release has breaking changes.

  • REFACTOR(package_info_plus): Migrate Android example to use the new plugins declaration (#2715). (33681cd9)
  • BREAKING FEAT(package_info_plus): Support multiple version.json locations in web (#2733). (26047f30)

6.0.0

Note: This release has breaking changes.

In this release plugin migrated from dart:html to js_interop, meaning that it now supports WASM!

Plugin now requires the following:

  • Flutter >=3.19.0

  • Dart >=3.3.0

  • compileSDK 34 for Android part

  • Java 17 for Android part

  • Gradle 8.4 for Android part

  • BREAKING REFACTOR(package_info_plus): bump MACOSX_DEPLOYMENT_TARGET from 10.11 to 10.14 (#2593). (99c832ea)

  • BREAKING BUILD(package_info_plus): Target Java 17 on Android (#2728). (23f2a7c2)

  • BREAKING BUILD(package_info_plus): Update to target and compile SDK 34 (#2707). (df33fbd)

  • FIX(package_info_plus): Add iOS Privacy Info (#2584). (895fe1a2)

  • FEAT(package_info_plus): Update min iOS target to 12, bump min Dart SDK to 3.3 (#2660). (6c0766dd)

  • FEAT(package_info_plus): Use js_interop instead of html to support compilation to WASM (#2625). (c9435836)

5.0.1

Note: This release has breaking changes.

  • BREAKING FIX(package_info_plus): Allow no page extension in versionJsonUrl on web (#2381). (32652b87)
  • BREAKING(package_info_plus): Bump min Dart to 3.2.0 and min Flutter to 3.6.0 to support pkg:web (#2316). (450aeb57)
  • FEAT(package_info_plus): Migrate to pkg:web from dart:html. (#2316). (450aeb57)

5.0.0

Note: This release was retracted due to (#2251).

4.2.0

Info: This release is a replacement for release 5.0.0, which was retracted due to issue (#2251). As breaking change was reverted the major release was also reverted in favor of this one.

  • FIX(package_info_plus): Change Kotlin version from 1.9.10 to 1.7.22 (#2254). (885a2a1f)
  • FIX(package_info_plus): Revert bump compileSDK to 34 (#2232). (e25e3902)
  • FEAT(package_info_plus): Remove deprecated VALID_ARCHS iOS property (#2023). (4e172576)
  • DOCS(package_info_plus): Add explanation for known issue on Windows (#2029). (87457bf4)

4.1.0

  • FIX(package_info_plus): proper version.json url for files with special characters (#2015). (235ee391)
  • FIX(package_info_plus): not working in Windows release mode from network location (#1931). (784caca5)
  • FIX(package_info_plus): Regenerate iOS and MacOS example apps (#1871). (0102fbbd)
  • FEAT(package_info_plus): Added toMap method (#1926). (4696ff45)
  • DOCS(all): Fix example links on pub.dev (#1863). (d726035a)

4.0.2

  • CHORE(package_info_plus): Update http dependency constraints (#1851)(#1851). (1463bea)

4.0.1

  • FIX(package_info_plus): Get Windows package info when app is on a network drive (#1697). (d7f9c28b)
  • FIX: Add jvm target compatibility to Kotlin plugins (#1798). (1b7dc432)
  • DOCS(all): Update READMEs (#1828). (57d9c884)
  • CHORE(package_info_plus): Win32 dependency upgrade (#1805). (3f68800)

4.0.0

Note: This release has breaking changes.

  • CHORE(package_info_plus): Update Flutter dependencies, set Flutter >=3.3.0 and Dart to >=2.18.0 <4.0.0
  • BREAKING FIX(all): Add support of namespace property to support Android Gradle Plugin (AGP) 8 (#1727). Projects with AGP < 4.2 are not supported anymore. It is highly recommended to update at least to AGP 7.0 or newer.
  • BREAKING CHORE(package_info_plus): Bump min Android to 4.4 (API 19) and iOS to 11, update podspec file (#1776).
  • REFACTOR(package_info_plus): Tidy up Windows implementation (#1768).
  • DOCS(package_info_plus): Explain why buildNumber returns version when no build number defined (#1729).

3.1.2

  • FIX(all): Revert addition of namespace to avoid build fails on old AGPs (#1725).

3.1.1

  • FIX(package_info_plus): remove html file parts from version url (#1330).
  • FIX(package_info_plus): Add compatibility with AGP 8 (Android Gradle Plugin) (#1704).

3.1.0

  • REFACTOR(all): Remove all manual dependency_overrides (#1628).
  • FIX(package_info_plus): Make example app content scrollable (#1614).
  • FIX(package_info_plus): Make installerStore an optional argument in mocks (#1547).
  • FIX(all): Fix depreciations for flutter 3.7 and 2.19 dart (#1529).
  • FEAT(package_info_plus): Use new API to get install source on Android >= 11 (#1616).

3.0.3

  • REFACTOR: Remove nullable struct fields (#1526).
  • DOCS: Fixed markdown table formatting in README (#1477).
  • DOCS: Updates for READMEs and website pages (#1389).

3.0.2

  • FIX: adds value equality for PackageInfo (#1328).

3.0.1

  • FIX: Increase min Flutter version to fix dartPluginClass registration (#1275).

3.0.0

Note: This release has breaking changes.

  • BREAKING REFACTOR: two-package federated architecture (#1236).
  • BREAKING REFACTOR: two-package federated architecture (#1228).

2.0.0

Note: This release has breaking changes.

  • BREAKING FEAT: Add information about the installer store (#1135).

1.4.3+1

  • Add issue_tracker link.

1.4.3

  • Windows: Updated package_info_plus_windows to version 2.0.0.
  • MacOS: Updated package_info_plus_macos to 1.3.0.
  • Updated test to 1.21.1.
  • Updated flutter_lints to 2.0.1.

1.4.2

  • Web: Resolve package_name
  • Linux: Resolve package_name

1.4.1

  • Windows: Fix MissingPluginException
  • Linux: Fix MissingPluginException

1.4.0

  • Android: Migrate to Kotlin
  • Android: Update dependencies, build config updates
  • Android: Fix project title

1.3.1

  • Fix embedding issue in example

1.3.0

  • Removed deprecated embeddingV1 function
  • Upgraded gradle and Android API version

1.2.1

  • Windows: Annotate int with external in preparation of Flutter 2.5

1.2.0

  • fix app name on iOS and macOS

1.1.0

  • migrate integration_test to flutter sdk

1.0.6

  • Web: Fixed url resolving for the version.json

1.0.5

  • Remove the required keyword of buildSignature in PackageInfo's constructor to restore backward compatibility

1.0.4

  • Add buildSignature to Android package info to retrieve the signing certifiate SHA1 at runtime.

1.0.3

  • Android: migrate to mavenCentral

1.0.2

  • Add cache buster to version.json

1.0.1

  • Improve documentation

1.0.0

  • Migrate to null-safety
  • Update dependencies
  • Fix dart SDK constraints

0.6.4

  • Add support for mock data during tests

0.6.3

  • Fix base URI resolving for Web
  • Fix platform interface dependency version for Linux

0.6.2

  • Fix collision with package_info

0.6.1

  • Fix package dependencies with the windows and web plugins

0.6.0

  • Changed method channel name
  • Moved Java files to different java package to avoid issues with package_info

0.5.0

  • Transfer to plus-plugins monorepo

0.4.5

  • package_info_plus now supports web platform and now uses package_info_platform_interface.

0.4.4

  • Transfer package to Flutter Community under new name package_info_plus.

0.4.3

  • Update package:e2e -> package:integration_test

0.4.2

  • Update package:e2e reference to use the local version in the flutter/plugins repository.

0.4.1

  • Add support for macOS.

0.4.0+18

  • Update lower bound of dart dependency to 2.1.0.

0.4.0+17

  • Bump the minimum Flutter version to 1.12.13+hotfix.5.
  • Clean up various Android workarounds no longer needed after framework v1.12.
  • Complete v2 embedding support.
  • Fix CocoaPods podspec lint warnings.

0.4.0+16

0.4.0+15

  • Replace deprecated getFlutterEngine call on Android.

0.4.0+14

  • Make the pedantic dev_dependency explicit.

0.4.0+13

  • Remove the deprecated author: field from pubspec.yaml
  • Migrate the plugin to the pubspec platforms manifest.
  • Require Flutter SDK 1.10.0 or greater.

0.4.0+12

  • Fix pedantic lints. This involved internally refactoring how the PackageInfo.fromPlatform code handled futures, but shouldn't change existing functionality.

0.4.0+11

  • Remove AndroidX warnings.

0.4.0+10

  • Include lifecycle dependency as a compileOnly one on Android to resolve potential version conflicts with other transitive libraries.

0.4.0+9

  • Android: Use android.arch.lifecycle instead of androidx.lifecycle:lifecycle in build.gradle to support apps that has not been migrated to AndroidX.

0.4.0+8

  • Support the v2 Android embedder.
  • Update to AndroidX.
  • Add a unit test.
  • Migrate to using the new e2e test binding.

0.4.0+7

  • Update and migrate iOS example project.
  • Define clang module for iOS.

0.4.0+6

  • Fix Android compiler warnings.

0.4.0+5

  • Add iOS-specific warning to README.md.

0.4.0+4

  • Add missing template type parameter to invokeMethod calls.
  • Bump minimum Flutter version to 1.5.0.
  • Replace invokeMethod with invokeMapMethod wherever necessary.

0.4.0+3

  • Add integration test.

0.4.0+2

  • Android: Using new method for BuildNumber in new android versions

0.4.0+1

  • Log a more detailed warning at build time about the previous AndroidX migration.

0.4.0

  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.

0.3.2+1

  • Fixed a crash on IOS when some of the package infos are not available.

0.3.2

  • Updated Gradle tooling to match Android Studio 3.1.2.

0.3.1

  • Added appName field to PackageInfo for getting the display name of the app.

0.3.0

  • Breaking change. Set SDK constraints to match the Flutter beta release.

0.2.1

  • Fixed Dart 2 type error.

0.2.0

  • Breaking change. Introduced class PackageInfo in place of individual functions.
  • PackageInfo provides all package information with a single async call.

0.1.1

  • Added package name to available information.
  • Simplified and upgraded Android project template to Android SDK 27.
  • Updated package description.

0.1.0

  • Breaking change. Upgraded to Gradle 4.1 and Android Studio Gradle plugin 3.0.1. Older Flutter projects need to upgrade their Gradle setup as well in order to use this version of the plugin. Instructions can be found here.

0.0.2

  • Add FLT prefix to iOS types

0.0.1

  • Initial release