[英]onTap of Container in flutter want to call a Callback and also setState of the container
I am new to dart and flutter. 我是飞镖和飞镖的新手。 I want to execute a callback onTap of a container as below:
我想执行一个容器的回调onTap,如下所示:
final VoidCallback onClick;
onTap: () {
widget.onClick; // this is the callback function
setState((){
isClicked = !isClicked;
});
},
However, when I execute the above code the callback is not executed. 但是,当我执行上述代码时,未执行回调。 However, when I write the code as below it is executed:
但是,当我编写如下代码时,它会执行:
onTap: widget.onClick,
How do I achieve to execute the callback ? 如何实现执行回调?
你应该用
widget.onClick()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.