首页 > 解决方案 > 使用 Flutter Web 1.9 打开外部链接

问题描述

我有一个 Flutter Web 项目,从 flutter_web 开始并迁移到 1.9,一切正常,但无法使外部链接工作。

堆栈溢出中有一些解决方案,但任何解决方案似乎都没有按预期工作,从这个链接 和类似的其他链接中尝试了所有解决方案,我认为接受的问题在 1.9 之前可以工作。

标签: flutter-web

解决方案


有了flutter 1.10,我们可以使用universal_html包打开外部链接:

import 'package:universal_html/prefer_universal/html.dart' as html;
// ...
html.window.location.assign('https://stackoverflow.com');

推荐阅读