javascript - Redirect only on Flutter Web - Stack Overflow

I'm trying to set up an app that uses a WebView (flutter_webview on pub) on Android and redirects

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).

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).

Share Improve this question asked May 9, 2021 at 17:09 samuelbeepsamuelbeep 152 silver badges5 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

When in web, just create a method like this:

import 'dart:html' as html;

void openInWindow(String uri, String name) {
  html.window.open(uri, name);
}

and use it like this:

print('heading over to... $uri');
openInWindow(uri.toString(), '_self');

import 'dart:html' as html; dont forget this import for previous solution

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745423998a4627092.html

相关推荐

  • javascript - Redirect only on Flutter Web - Stack Overflow

    I'm trying to set up an app that uses a WebView (flutter_webview on pub) on Android and redirects

    5小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信