I’m trying to set up an app that uses a WebView (flutter_webview on pub) on Android and redirects directly on web, as flutter_webview does not work on web. I looked into js on pub and dart:js but that does not work, as Android doesn’t allow dart:js or package:js to be imported at all. Any ideas? I’m using kIsWeb to detect the platform (not offering iOS or Desktop).
Advertisement
Answer
When in web, just create a method like this:
JavaScript
x
6
1
import 'dart:html' as html;
2
3
void openInWindow(String uri, String name) {
4
html.window.open(uri, name);
5
}
6
and use it like this:
JavaScript
1
3
1
print('heading over to... $uri');
2
openInWindow(uri.toString(), '_self');
3