Cast a variable as a function/method pointer in Dart? (Delegate?) Cast a variable as a function/method pointer in Dart? (Delegate?) dart dart

Cast a variable as a function/method pointer in Dart? (Delegate?)


You can use Function as type or if you also want to specify the arguments and return type of these functions you can create typedefs.

Map<String, Function> triggerHandler = {  'x' : (t) => hello(t)};
typedef int SomeName(SomeType arg1);Map<String, SomeName> triggerHandler = {  'x' : (t) => hello(t)};