|
|
|
|
@ -1057,9 +1057,42 @@ class Utils {
|
|
|
|
|
return isHavePrivilege;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void openWebView({required String url}) {
|
|
|
|
|
static Future<void> openWebView({required String url}) async {
|
|
|
|
|
try {
|
|
|
|
|
Uri uri = Uri.parse(url);
|
|
|
|
|
launchUrl(uri, mode: LaunchMode.inAppBrowserView);
|
|
|
|
|
|
|
|
|
|
// Validate URL scheme for in-app browser
|
|
|
|
|
if (!uri.hasScheme || (!uri.scheme.startsWith('http'))) {
|
|
|
|
|
throw 'Invalid URL scheme. In-app browser only supports HTTP/HTTPS URLs';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if URL can be launched
|
|
|
|
|
if (await canLaunchUrl(uri)) {
|
|
|
|
|
final launched = await launchUrl(
|
|
|
|
|
uri,
|
|
|
|
|
mode: LaunchMode.externalApplication,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!launched) {
|
|
|
|
|
// Fallback to external browser
|
|
|
|
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Fallback to external browser
|
|
|
|
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
debugPrint('❌ Failed to open URL: $url - Error: $e');
|
|
|
|
|
|
|
|
|
|
// Try external browser as last resort
|
|
|
|
|
try {
|
|
|
|
|
final uri = Uri.parse(url);
|
|
|
|
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
|
|
|
} catch (e2) {
|
|
|
|
|
debugPrint('❌ Failed to open URL in external browser: $e2');
|
|
|
|
|
// Optionally show user-friendly error message
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Color getCardBorderColor(int currentQueueStatus) {
|
|
|
|
|
|