handleOverrideUrl method
Implementation
Future<bool> handleOverrideUrl(BuildContext context, String? requestedUrl) async {
if (requestedUrl == null) {
return false;
} else {
Success? success = successFromUrl(requestedUrl);
Fail? fail = failFromUrl(requestedUrl);
bool isCanceled;
try {
isCanceled = Uri.parse(requestedUrl).queryParameters['code']?.toUpperCase() == 'PAY_PROCESSED_CANCELED';
} catch (_) {
isCanceled = false;
}
if (success != null) {
Navigator.pop(context, success);
return true;
} else if (fail != null || isCanceled) {
Navigator.pop(context, fail);
return true;
}
final convertUrl = ConvertUrl(requestedUrl);
final isHtml = requestedUrl.startsWith('data:text/html');
final isNetworkUrl = convertUrl.appScheme == 'http' || convertUrl.appScheme == 'https';
final isJavascriptUrl = requestedUrl.startsWith('javascript:');
bool isIntent;
try {
isIntent = Uri.parse(requestedUrl).scheme == 'intent';
} catch (_) {
isIntent = false;
}
final isMarket = convertUrl.appScheme == 'market' || convertUrl.appScheme == 'onestore';
if (isHtml || isJavascriptUrl) {
return false;
} else if (isIntent || isMarket) {
await convertUrl.launchApp();
return true;
} else if (isNetworkUrl) {
if (Platform.isAndroid) {
if (requestedUrl.startsWith('https://onesto.re') || requestedUrl.startsWith('https://m.onestore')) {
await convertUrl.launchApp();
return true;
}
}
return false;
} else {
await convertUrl.launchApp();
return true;
}
}
}