database - 让 webview 在 flutter 上使用某些触发器更改数据

标签 database flutter dart mobile webview

我有一个带有单选小部件的 flutter 测验项目,当按下下一个按钮时,数据将更改(更改问题)我尝试在问题或问题文本上使用 WebView,但没有数据更改,

以下是带有文字的测验

Container(
     width: 250,
     child: new Text(
                                             
     "${dataQuestions["list_question"][_counter]["data_option"][loop]["option_text"]}",
     maxLines: 2,
     overflow: TextOverflow.ellipsis,),)

我用 WebView 做的

new Container(
    height: 50,
    width: 250,
    child: WebView(
        initialUrl: '${dataQuestions["list_question"][_counter]["data_option"][loop]["option_text"]}',
        javascriptMode: JavascriptMode.unrestricted,
        onWebViewCreated: (WebViewController webViewController) {
        _controller.complete(webViewController);},
    )),

最佳答案

首先为您的WebView创建一个 Controller

WebViewController _webViewController = WebViewController();

然后将其分配给webview

new Container(
height: 50,
width: 250,
child: WebView(
    controller: _webViewController,
    initialUrl: '${dataQuestions["list_question"][_counter]["data_option"][loop]["option_text"]}',
    javascriptMode: JavascriptMode.unrestricted,
    onWebViewCreated: (WebViewController webViewController) {
    _controller.complete(webViewController);},
)),

在您的 nextButton 按下回调中(您正在增加 _counter 和循环变量)通过 _webViewController 加载下一个

_webViewController.loadUrl('${dataQuestions["list_question"][_counter]["data_option"][loop]["option_text"]}');

关于database - 让 webview 在 flutter 上使用某些触发器更改数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66881310/

相关文章:

android - 弹出键盘时如何避免重新加载整页?

ruby-on-rails - 在 rails 中建模嵌套模型

flutter - 使用 Flutter web 生成 PDF 文件

flutter - 如何检测 flutter 中的阻力速度?

dart - flutter 错误 : Document references must have an even number of segments

从另一个屏幕移回屏幕后 flutter 调用函数

json - Flutter json_serializable 生成的 json 代码在 Firebase 数据库中保存为字符串

sql - 根据表中存储的值从表中选择列

mysql - 当字符串包含空格时应用程序不更新数据库

php - 选择字符串中的所有字符直到特定字符 MySQL