这是对this question的后续调查,询问这一切是否可能.
这WebView
package人看起来真的很傻.但到目前为止,它对我来说似乎真的很晦涩和密集.
我所能找到的几乎所有的例子都指的是看到其他现有的Web页面,然后对它们进行更改,但我的用例是关于有一个空页面,在这个页面中,我将使用更成熟的JS可视化库来绘制图表或图形.
我也不清楚,但这个包是关于为非Web环境添加视图的吗?如果是这样的话,在Ffltter Web上使用它会怎么样?也许这对有经验的人来说是显而易见的,但对于那些开始使用它的人来说,这一点一点都不清楚……
例如,我正在try 实现this simple D3.js example,在包的文档中有这个简单的示例:
import 'dart:io';
import 'package:webview_flutter/webview_flutter.dart';
class WebViewExample extends StatefulWidget {
@override
WebViewExampleState createState() => WebViewExampleState();
}
class WebViewExampleState extends State<WebViewExample> {
@override
void initState() {
super.initState();
// Enable virtual display.
if (Platform.isAndroid) WebView.platform = AndroidWebView();
}
@override
Widget build(BuildContext context) {
return WebView(
initialUrl: 'https://flutter.dev',
);
}
}
我不知道在Web的情况下,我会为WebView.platform
做什么,没有 Select .而且,当我在Chrome上试用它时,我得到--我在Linux上使用了Chrome,而我的应用does的其余部分--:
The following UnsupportedError was thrown building WebView(dirty, state: _WebViewState#2d89e):
Unsupported operation: Trying to use the default webview implementation for TargetPlatform.linux
but there isn't a default one
我确实try 了上面代码的其他变体,包括try 将其设置为不带initState
的StatelessWidget
,但结果是相同的:
class WebViewExample extends StatelessWidget {
const WebViewExample({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: WebView(
initialUrl: 'https://flutter.dev',
),
);
}
}
有没有人能在Flutter 网上完成the simple D3.js example I mentioned次(如果你能把数据从DART发送到JS就更好了……)?那将会有很大的帮助.