fetchVersion function

Future<AppVersionData> fetchVersion({
  1. String? playStoreId,
  2. String? appleId,
  3. String? country,
})

Fetch version regarding platform.

  • appleId unique identifier in Apple Store, if null, we will use your package name.
  • playStoreId unique identifier in Play Store, if null, we will use your package name.
  • country (iOS only) region of store, if null, we will use 'us'.

Implementation

Future<AppVersionData> fetchVersion(
    {String? playStoreId, String? appleId, String? country}) async {
  final packageInfo = await PackageInfo.fromPlatform();
  AppVersionData data = AppVersionData();
  if (Platform.isAndroid) {
    data =
        await fetchAndroid(packageInfo: packageInfo, playStoreId: playStoreId);
  } else if (Platform.isIOS) {
    data = await fetchIOS(
      packageInfo: packageInfo,
      appleId: appleId,
      country: country,
    );
  } else {
    throw "Unknown platform";
  }
  data.canUpdate = await convertVersion(
      version: data.localVersion, versionStore: data.storeVersion);
  return data;
}