openFunction method
Future<void>
openFunction({
- required BuildContext context,
- required AppsModel data,
- required bool installed,
Implementation
Future<void> openFunction(
{required BuildContext context,
required AppsModel data,
required bool installed}) async {
if (Platform.isAndroid) {
if (data.open == 'store') {
launchUrl(Uri.parse(data.android.store));
return;
}
if (data.open == 'web') {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => InAppWebview(url: data.webUrl)));
return;
}
if (data.open == 'app') {
if (installed) {
Uri playstoreURL = Uri.dataFromString(data.android.store);
String id = playstoreURL.queryParameters['id']!;
DeviceApps.openApp(id);
return;
}
launchUrl(Uri.parse(data.android.store));
return;
}
}
if (Platform.isIOS) {
if (data.open == 'store') {
launchUrl(Uri.parse(data.ios.store));
return;
}
if (data.open == 'web') {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => InAppWebview(url: data.webUrl)));
return;
}
if (data.open == 'app') {
if (installed) {
launchUrl(Uri.parse(data.ios.scheme));
return;
}
launchUrl(Uri.parse(data.ios.store));
return;
}
}
}