You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
voidmain(){
var res =exec(select('sum'),1 ,2);
print(res);
}
Functionselect(String opType){
if(opType =='sum') return sum;
if(opType =='sub') return sub;
return (a, b) =>0;
}
intexec(NumberOp op, int a, int b){
returnop(a,b);
}
intsum(int a, int b) => a + b;
intsub(int a, int b) => a - b;
typedefNumberOp=Function (int a, int b);
Error: The argument type 'Function' can't be assigned to the parameter type 'dynamic Function(int, int)'.
页面 URL
https://flutter.cn/community/tutorials/deep-dive-into-dart-s-function-closure/
页面源代码地址
https://github.com/cfug/flutter.cn/tree/main/src/community/tutorials/deep-dive-into-dart-s-function-closure.md
描述问题
实现策略模式中,代码错误
Error: The argument type 'Function' can't be assigned to the parameter type 'dynamic Function(int, int)'.
期望如何修复
附加信息
No response
我希望能自己修复这个问题
The text was updated successfully, but these errors were encountered: