fetchAndroid function
Implementation
Future<AppVersionData> fetchAndroid(
{PackageInfo? packageInfo, String? playStoreId, String? country}) async {
playStoreId = playStoreId ?? packageInfo?.packageName;
final parameters = {"id": playStoreId, "hl": country};
var uri = Uri.https(playStoreAuthority, playStoreUndecodedPath, parameters);
final response =
await http.get(uri, headers: headers).catchError((e) => throw e);
if (response.statusCode == 200) {
final versionMatch =
RegExp(r',\[\[\["([0-9,\.]*)"]],').firstMatch(response.body);
if (versionMatch != null) {
return AppVersionData(
storeVersion: versionMatch.group(1),
storeUrl: uri.toString(),
localVersion: packageInfo?.version,
targetPlatform: TargetPlatform.android,
);
} else {
throw " Aplication not found in Play Store, verify your app id. ";
}
} else {
throw " Aplication not found in Play Store, verify your app id. ";
}
}