getPackageInfo function

Future<PackageInfoData> getPackageInfo()

Implementation

Future<PackageInfoData> getPackageInfo() async {
  if (isAndroid || isIOS) {
    var data = await invokeNativeMethod(channelName, 'packageInfo');

    if (data != null && data is Map) {
      return PackageInfoData(
        appName: data['appName'],
        packageName: data['packageName'],
        versionName: data['versionName'],
        versionCode: data['versionCode'],
        androidSDKVersion: data['androidSDKVersion'],
      );
    } else {
      throw errorSomethingWentWrong;
    }
  } else {
    return PackageInfoData();
  }
}