使用 onTapLink 时出错:无法分配参数类型 'void Function(String, String, String)'
Error when using onTapLink: argument type can't be assigned 'void Function(String, String, String)'
我正在尝试在我的 Markdown 小部件中实现 onTapLink(使用 flutter_markdown 库)。互联网上到处都告诉你使用
onTapLink: (url) => launch(url),
或
onTapLink: (url){
launch(url);
},
但是当我这样做时我得到了错误
The argument type 'Future Function(String)' can't be assigned to the parameter type 'void Function(String, String, String)'.
当我搜索 'flutter_markdown' api 定义时,'onTapLink' 有 3 个参数。
https://github.com/flutter/flutter_markdown/blob/1433d0fcb0cbc775bb258ab3dea720e764e42f92/lib/src/widget.dart#L22
所以,虽然你不需要其他参数,但你需要定义和使用你想要的参数。
onTapLink: (text, href, title) {
launch(href);
}
我正在尝试在我的 Markdown 小部件中实现 onTapLink(使用 flutter_markdown 库)。互联网上到处都告诉你使用
onTapLink: (url) => launch(url),
或
onTapLink: (url){
launch(url);
},
但是当我这样做时我得到了错误
The argument type 'Future Function(String)' can't be assigned to the parameter type 'void Function(String, String, String)'.
当我搜索 'flutter_markdown' api 定义时,'onTapLink' 有 3 个参数。
https://github.com/flutter/flutter_markdown/blob/1433d0fcb0cbc775bb258ab3dea720e764e42f92/lib/src/widget.dart#L22
所以,虽然你不需要其他参数,但你需要定义和使用你想要的参数。
onTapLink: (text, href, title) {
launch(href);
}