flutter - 在后台打开网站并在 Flutter 应用程序中访问其字段
问题描述
在我的颤振应用程序中,我想从特定网站上的文本字段中读取和写入。我正在谈论的网站没有后端,当您在其计算字段中输入值时,它会在浏览器中执行 javascript 代码。我想将我的应用程序中的值读/写到这些文本字段中。是否可以使用 webview 来实现这一点?这可能吗?如果可能的话,我不想将用户拉出我的应用程序 ui。为自己实施计算工具会花费大量时间。
解决方案
这是开始的一种方法。这使用本地托管的文件作为 web 视图,但没有理由不能将其调整为公共网站。
RaisedButton(
onPressed: () {
showAboutDialog(
context: context,
children: [
Column(mainAxisSize: MainAxisSize.min, children: [
Text("Please don't sue me"),
Container(
height: 160,
child: SingleChildScrollView(
child: Container(
height: 180,
child: WebView(
initialUrl: "",
javascriptMode: JavascriptMode.unrestricted,
// this is defined elsewhere and fixes a (at one time) bug with gesture detection
gestureRecognizers: [
Factory(() =>
PlatformViewVerticalGestureRecognizer()),
].toSet(),
onWebViewCreated: (WebViewController
webViewController) async {
_controller = webViewController;
await loadHtmlFromAssets(
'public/index.html', _controller);
},
),
),
),
),
]),
],
applicationVersion: "Version 0.1",
applicationName: "Your Application",
applicationLegalese: "",
applicationIcon:
ImageIcon(AssetImage("assets/images/pos_icon.png")));
},
child: Text("About, and Legalese for masochists"),
),
推荐阅读
- html - 为什么 SVG 路径上的遮罩没有正确遮罩?
- android - 如何在xml或java中获取字体文件夹
- three.js - 三.js 通过名称属性值获取所有网格。
- javascript - ReactJS Starter - 意外的令牌 JSX
- sql-server - TSQL 将数据库 BLOB 提取到临时表中
- r - 如何在 R 中没有任何类别分组的情况下将 ggplot2 用于条形图?
- azure - 将 B2C 重定向 URL 设置为 b2clogin.com 时,我在哪里可以将 validateAuthority 设置为 false
- python - 考虑不确定性的高斯拟合
- asp.net-mvc - 防止在 ASP.NET MVC 中为某些视图搭建脚手架
- angularjs - 根据自定义 ui-grid 上的值启用和禁用单元格选择