A typedef gives a reusable name to a function type. This keeps callback-heavy code readable: the variable, parameter, and helper all agree on the same function shape without repeating int Function(int, int) everywhere.

Program

Play the program to store one binary operation alias, switch it with a selector, and call it through a helper.

typedef_function_aliases.dart
typedef IntOp = int Function(int left, int right);

int apply(int left, int right, IntOp op) {
  return op(left, right);
}

int add(int left, int right) => left + right;
int multiply(int left, int right) => left * right;

void main() {
  var mode = ;
  IntOp op = mode == 'add' ? add : multiply;
  var result = apply(3, 4, op);
  print('$mode=$result');
}
typedef IntOp = int Function(int left, int right);

int apply(int left, int right, IntOp op) {
  return op(left, right);
}

int add(int left, int right) => left + right;
int multiply(int left, int right) => left * right;

void main() {
  var mode = ;
  IntOp op = mode == 'add' ? add : multiply;
  var result = apply(3, 4, op);
  print('$mode=$result');
}
typedef `typedef IntOp = int Function(int left, int right);` names a function shape once.
alias in declarations `IntOp op` is easier to read than repeating the full function type at every variable or parameter.
same runtime behavior A typedef is a static type alias; calling `op(3, 4)` still runs the actual function value stored in `op`.