2023-05-03 16:30:20 +02:00
|
|
|
import 'dart:io';
|
|
|
|
|
2023-04-06 22:56:32 +02:00
|
|
|
import 'package:flutter_web_browser/flutter_web_browser.dart';
|
2023-05-03 16:30:20 +02:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2023-04-06 22:56:32 +02:00
|
|
|
|
2023-05-03 16:30:20 +02:00
|
|
|
void openUrl(String url) async {
|
|
|
|
if (Platform.isAndroid || Platform.isIOS) {
|
|
|
|
FlutterWebBrowser.openWebPage(
|
|
|
|
url: url,
|
|
|
|
customTabsOptions: const CustomTabsOptions(
|
|
|
|
instantAppsEnabled: true,
|
|
|
|
showTitle: true,
|
|
|
|
urlBarHidingEnabled: false,
|
|
|
|
),
|
|
|
|
safariVCOptions: const SafariViewControllerOptions(
|
|
|
|
barCollapsingEnabled: true,
|
|
|
|
dismissButtonStyle: SafariViewControllerDismissButtonStyle.close,
|
|
|
|
modalPresentationCapturesStatusBarAppearance: true,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
final uri = Uri.parse(url);
|
|
|
|
if (await canLaunchUrl(uri)) {
|
|
|
|
await launchUrl(uri);
|
|
|
|
} else {
|
|
|
|
throw 'Could not launch $url';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|