skip to Main Content

I am new to flutter and working on build html widget using flutter_html with version flutter_html^3.0.0-beta.2. With the recent version updates I am getting one error for onLinkTap function. Please help me on resolving this. Following is the code and error message i am getting.

static Widget getHTMLWidget(String htmlContent, Function onTap) {
 return Html(
  shrinkWrap: true,
  data: htmlContent,
  onLinkTap: (
    String? url, 
    RenderContext renderContext,
    Map<String, String> attributes, element
  ) async {
    onTapFunction();
  },
);

}
Error from IDE is,

The argument type ‘void Function(String?, Map<String, String>, Map<String, String>, dynamic)’ can’t be assigned to the parameter type ‘void Function(String?, Map<String, String>, Element?)?’.dartargument_type_not_assignable

2

Answers


  1. Chosen as BEST ANSWER

    As per the latest version code changes we need to call the function like below,

    Html(
     shrinkWrap: true,
     data: htmlContent,
     onLinkTap: (url, _, __) {
      onTapFunction();
     }
    );
    

  2. This version isn’t ready for production. It’s probably that the documentation isn’t ready yet.

    The latest release version of this package is flutter_html: ^2.2.1 according to the docs on dart.pub as you can check here

    And if this worked before, maybe the arguments of this method were changed and we couldn’t know without the docs. If you really need to test this beta version, try to open an Issue on their Github Repository.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search