21 lines
633 B
Dart
21 lines
633 B
Dart
import 'dart:js_interop';
|
|
import 'dart:js_interop_unsafe';
|
|
|
|
/// Web external open: a new browser tab. The url is already validated by
|
|
/// [resolveArtifactUrl]; it is passed through unchanged and never fetched.
|
|
///
|
|
/// `window.open` is reached through `js_interop` rather than `dart:html`, so the
|
|
/// same source compiles for both the JavaScript and WebAssembly web targets.
|
|
Future<bool> openArtifactExternally(Uri uri) async {
|
|
try {
|
|
final opened = globalContext.callMethod(
|
|
'open'.toJS,
|
|
uri.toString().toJS,
|
|
'_blank'.toJS,
|
|
);
|
|
return opened.isDefinedAndNotNull;
|
|
} catch (_) {
|
|
return false;
|
|
}
|
|
}
|