fetchVersion function
Fetch version regarding platform.
appleIdunique identifier in Apple Store, if null, we will use your package name.playStoreIdunique identifier in Play Store, if null, we will use your package name.country, 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, country: country);
} else if (Platform.isIOS) {
data = await fetchIOS(
packageInfo: packageInfo, appleId: appleId, country: country);
} else {
throw "Unkown platform";
}
data.canUpdate = await convertVersion(
version: data.localVersion, versionStore: data.storeVersion);
return data;
}