Flutter onTap从htmlWidget

时间:2019-09-10 06:06:52

标签: flutter flutter-dependencies flutter-test

我有来自Json的html并将其保存在String中,然后使用flutter_widget_from_html依赖项将html视为webview

我想在htmlWidget中的onTap上获取特定的图像URL。 在android系统中,我有onTouchListener可以从中轻松提取图像,但是我不知道如何在Flutter中进行处理。

Directionality(textDirection: TextDirection.rtl,
  child: HtmlWidget("<p><img class="alignnone size-full wp-image-231636" src="http://abc/wp-content/uploads/2019/09/big13-48.jpg" alt="" width="600" height="800" srcset="http://abc/wp-content/uploads/2019/09/big13-48.jpg 600w, http://abc/wp-content/uploads/2019/09/big13-48-450x600.jpg 450w" sizes="(max-width: 600px) 100vw, 600px" /></p>", 
    webView: true,
  ),
),

2 个答案:

答案 0 :(得分:0)

您可以使用builderCallback做到这一点。它提供了在渲染时自定义UI小部件的功能。

跟随该URL。 https://github.com/daohoangson/flutter_widget_from_html/issues/50#issuecomment-500928520

答案 1 :(得分:0)

dependencies:
  flutter_html: ^0.11.0

您将在其中收到该图像。

 onImageTap: (src) {
   // Display the image in large form.
}

参考链接:

https://github.com/Sub6Resources/flutter_html