getPackageInfo static method

Future<PackageInfo> getPackageInfo()

Get the app's PackageInfo (version, build number, etc.) This is cached after the first call for better performance.

Example usage:

final info = await AppConfigBase.getPackageInfo();
print('Version: ${info.version}');
print('Build: ${info.buildNumber}');

Implementation

static Future<PackageInfo> getPackageInfo() async {
  _cachedPackageInfo ??= await PackageInfo.fromPlatform();
  return _cachedPackageInfo!;
}