Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何将http url链接到Flatter web_Flutter_Dart_Flutter Web_Openurl - Fatal编程技术网

Flutter 如何将http url链接到Flatter web

Flutter 如何将http url链接到Flatter web,flutter,dart,flutter-web,openurl,Flutter,Dart,Flutter Web,Openurl,我正在学习颤振网络。 单击按钮时,我试图打开另一个url。 有没有这样的方法: onclick:()=>openurl(“https://test.com” 我如何才能做到这一点? 请帮助有一个插件可以实现这一点: 导入插件 import 'package:url_launcher/url_launcher.dart'; openURL() async { const url = 'https://test.com'; if (await canLaunch(url)) { a

我正在学习颤振网络。
单击按钮时,我试图打开另一个url。 有没有这样的方法:
onclick:()=>openurl(“https://test.com”

我如何才能做到这一点?

请帮助

有一个插件可以实现这一点:

导入插件

import 'package:url_launcher/url_launcher.dart';

openURL() async {
  const url = 'https://test.com';
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';
  }
}

调用该方法

flatterweb不支持插件(尚未),因此您必须使用来自
dart:html

window.open(url,'tab')


window.location.assign(url)

当前最简单的方法是使用
href
和您的
html
库:

import 'dart:html' as html;

html.window.location.href = "https://www.google.com" // or any website your want

将该代码放入您的
onTap
方法中,就这样。

您现在可以使用
url\u启动器
,就像其他平台一样,添加了web支持


我无法导入dart插件。我得到了这个错误:因为webapp依赖于url_launcher>=3.0.0,它需要flatter SDK,所以版本解决失败。Flatter用户应该运行
flatterpackages-get
而不是
pub-get
。请查找更多详细信息,我无法在Flatter web中导入本机Flatter插件。Flatter web目前不支持插件。任何插件。如何使用post参数导航到另一个页面,“html.window.location.href”仅适用于get参数