Search code examples
flutterflutter-html

onTapImage in Html widget doesn't work (version 3.0.0-alpha.6)


enter image description here

On the package page it says I can use the 'onImageTap' argument to provide a function when an image is tapped in the Html widget.
Here it says that there is no such parameter.
Can you help me out, I really need newer version cause a lot of packages depend on it. I can't use 2.2.1 version.


Solution

  • If you check the Migration guide you will see that:

    onImageTap
    This parameter is removed. Instead, add the OnImageTapExtension:

    Html(
      data: ...,
      extensions: [
        OnImageTapExtension(
          onImageTap: (src, imgAttributes, element) {
            // Handle an image being tapped
          },
        ),
      ],
    )