当我执行onHover: function(context)时,它会给出错误
但是onHover: (event) => function(context)运行得很好。
有什么区别?onHover应该总是有一个变量(PointerHoverEvent)吗?
发布于 2020-07-28 18:40:28
function(context);可能会返回onHover参数不想要的东西,onHover参数想要一个函数,在这里onHover: (event) => function(context)你给它的是参数想要的函数,
给你一个概念
//this is a function
Function functionWhichReturnsInt = (){return 1;};
//this is function which needs function
void feedMeAFunction(Function food){
food();
}
//this is a function which needs int
void feedMeAnInt(int food){
print(food);
}
//we can call the functions like this
//passing a function
feedMeAFunction(functionWhichReturnsInt);
//passing an int
feedMeAnInt(functionWhichReturnsInt());https://stackoverflow.com/questions/63128309
复制相似问题