I'm pretty inexperienced with Flutter, I created a widget with this piece of code inside:
With code written like this: (the ToolModify function is not called)
final VoidCallback ToolModify;
onTap: () {
// rest of the code
widget.ToolModify;
},
.
instead, it is called with code written like this:
onTap: widget.ToolModify,
.
Can anyone explain to me why this happens?
Since I need to write other lines of code besides widget.ToolModify; how can i call the ToolModify function inside OnTap: () {...} ??
Hope someone can help me. Thanks :)
CodePudding user response:
you need to actually call the method:
onTap: () {
// rest of the code
widget.ToolModify(); // notice the brackets
},