url launch support
This commit is contained in:
parent
40bad1e06e
commit
dca9ee1939
3 changed files with 56 additions and 28 deletions
23
lib/helpers/launch_helper.dart
Normal file
23
lib/helpers/launch_helper.dart
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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<void> launchUrl(Uri url, {bool useWebview = false}) async {
|
||||
try {
|
||||
await ul.launchUrl(
|
||||
url,
|
||||
mode: useWebview
|
||||
? ul.LaunchMode.inAppBrowserView
|
||||
: ul.LaunchMode.externalApplication,
|
||||
);
|
||||
} on PlatformException catch (_) {
|
||||
// Ignore missing intent handler error
|
||||
}
|
||||
}
|
||||
|
||||
static final provider = Provider<LaunchHelper>(LaunchHelper.new);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue