【问题标题】:Flutter onTap get particular Image source from htmlWidgetFlutter onTap 从 htmlWidget 获取特定的图像源
【发布时间】:2020-01-11 20:41:41
【问题描述】:

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

我想在htmlWidget 中获取特定的图像 url onTap 特定图像。 在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,
  ),
),

【问题讨论】:

  • 您能在此处添加该html字符串吗?
  • @AmitPrajapati 我已经编辑了代码。

标签: flutter flutter-dependencies flutter-test


【解决方案1】:

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

关注这个网址。 https://github.com/daohoangson/flutter_widget_from_html/issues/50#issuecomment-500928520

【讨论】:

  • 它工作。我不知道什么是最好的方式来感谢你。我被困在这个问题上一个多星期了。谢谢bhai
  • 没问题的哥们:)
【解决方案2】:
dependencies:
  flutter_html: ^0.11.0

您将在其中收到该图像。

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

参考链接:

https://github.com/Sub6Resources/flutter_html

【讨论】:

  • 我在 html 字符串中有内联 Css,但不幸的是,这个(flutter_html)依赖项不适用于它。感谢您的帮助
猜你喜欢
  • 2019-05-27
  • 1970-01-01
  • 2022-06-15
  • 2019-05-31
  • 2015-08-24
  • 1970-01-01
  • 2015-12-14
  • 2012-05-22
  • 2021-06-23
相关资源
最近更新 更多