forked from Nexus/nexus
Now this feature is stable, we should use it. I might have missed some usecases, but these can be added in future commits.
21 lines
561 B
Dart
21 lines
561 B
Dart
import "package:flutter/services.dart";
|
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
|
import "package:url_launcher/url_launcher.dart" as ul;
|
|
|
|
class LaunchHelper {
|
|
final Ref ref;
|
|
LaunchHelper(this.ref);
|
|
|
|
Future<bool> launchUrl(Uri url, {bool useWebview = false}) async {
|
|
try {
|
|
return await ul.launchUrl(
|
|
url,
|
|
mode: useWebview ? .inAppBrowserView : .externalApplication,
|
|
);
|
|
} on PlatformException catch (_) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
static final provider = Provider<LaunchHelper>(LaunchHelper.new);
|
|
}
|