Skip to content
Justice Tech School

typedef and Callbacks

typedef names a function type so callbacks read clearly.

Example
typedef Op = int Function(int, int);
int run(Op f, int a, int b) => f(a, b);
print(run((a, b) => a + b, 2, 3));
print(run((a, b) => a * b, 2, 3));

Exercise

Name a type.

 Op = int Function(int);

Quiz Test

What does typedef create?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.