Dart 中具有已定义签名的函数列表
List of functions with defined signature in Dart
在 Dart 中,是否可以有一个函数列表,这些函数具有定义明确的签名?我正在寻找类似
的内容
List<(int, int) -> int> listOfFunctions;
这当然是错误的。
我可以
List<Function> listOfFunctions;
但是我不知道签名。
感谢任何提示。
只需为您的函数创建一个 typedef
typedef int MyFunction(int a, int b);
List<MyFunction> listOfFunctions;
在 Dart 中,是否可以有一个函数列表,这些函数具有定义明确的签名?我正在寻找类似
的内容List<(int, int) -> int> listOfFunctions;
这当然是错误的。
我可以
List<Function> listOfFunctions;
但是我不知道签名。
感谢任何提示。
只需为您的函数创建一个 typedef
typedef int MyFunction(int a, int b);
List<MyFunction> listOfFunctions;