英文:
flutter_html onLinkTap function giving error
问题
以下是翻译好的部分:
我是Flutter的新手,正在使用flutter_html的版本flutter_html^3.0.0-beta.2构建HTML小部件。随着最近的版本更新,我在onLinkTap函数上遇到了一个错误。
以下是代码:
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();
},
);
}
IDE中的错误信息是:
“参数类型'void Function(String?, Map<String, String>, Map<String, String>, dynamic)'无法分配给参数类型'void Function(String?, Map<String, String>, Element?)?'。”
英文:
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.
Following is the code:
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
答案1
得分: 1
这个版本还没有准备好投入生产使用。可能是因为文档还没有准备好。
根据 dart.pub
上的文档,这个包的最新发布版本是 flutter_html: ^2.2.1
,您可以在这里检查。
如果之前可以正常工作,可能是这个方法的参数已经更改了,没有文档我们就不知道。如果您真的需要测试这个 beta 版本,请尝试在他们的 GitHub 存储库上提出问题。
英文:
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.
答案2
得分: 0
根据最新版本的代码更改,我们需要按照以下方式调用该函数:
Html(
shrinkWrap: true,
data: htmlContent,
onLinkTap: (url, _, __) {
onTapFunction();
}
);
英文:
As per the latest version code changes we need to call the function like below,
Html(
shrinkWrap: true,
data: htmlContent,
onLinkTap: (url, _, __) {
onTapFunction();
}
);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论