2024-01-29 16:09:07 +01:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter_custom_tabs/flutter_custom_tabs.dart' as flutter_custom_tabs;
|
|
|
|
import 'package:url_launcher/url_launcher.dart' as url_launcher;
|
2024-01-29 02:37:45 +01:00
|
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
2023-04-06 22:56:32 +02:00
|
|
|
|
2023-05-03 16:30:20 +02:00
|
|
|
void openUrl(String url) async {
|
2024-01-29 16:09:07 +01:00
|
|
|
if (Platform.isAndroid || Platform.isIOS) {
|
|
|
|
try {
|
|
|
|
await flutter_custom_tabs.launchUrl(
|
|
|
|
Uri.parse(url),
|
|
|
|
customTabsOptions: const flutter_custom_tabs.CustomTabsOptions(
|
|
|
|
shareState: flutter_custom_tabs.CustomTabsShareState.browserDefault,
|
|
|
|
urlBarHidingEnabled: true,
|
|
|
|
showTitle: true,
|
|
|
|
),
|
|
|
|
safariVCOptions: const flutter_custom_tabs.SafariViewControllerOptions(
|
|
|
|
barCollapsingEnabled: true,
|
|
|
|
dismissButtonStyle: flutter_custom_tabs.SafariViewControllerDismissButtonStyle.close,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} catch (e, stackTrace) {
|
|
|
|
Sentry.captureException(e, stackTrace: stackTrace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
try {
|
|
|
|
url_launcher.launchUrl(Uri.parse(url));
|
|
|
|
} catch (e, stackTrace) {
|
|
|
|
Sentry.captureException(e, stackTrace: stackTrace);
|
|
|
|
}
|
2023-05-03 16:30:20 +02:00
|
|
|
}
|
|
|
|
}
|