typedef ManyOperation(int firstNo , int secondNo);
//function signature  

Add(int firstNo,int second){
   print("Add result is ${firstNo+second}");
}
Subtract(int firstNo,int second){
   print("Subtract result is ${firstNo-second}");
}
Divide(int firstNo,int second){
   print("Divide result is ${firstNo/second}");
}  
Calculator(int a, int b, ManyOperation oper){
   print("Inside calculator");
   oper(a,b);
}  
void main(){
   ManyOperation oper = Add;
   oper(10.20);
   oper = Subtract;
   oper(30.20);
   oper = Divide;
   oper(50.5);
}
Copy the code

The above code results in an error if the typedef variable tries to point to a function with a different function signature.

typedef Fly = void Function(int value); void main(){ Bird bird = Bird((int a){print(a); }); Bird.fly (3) will not be compiled if the argument function is not of that type; } /// (int a){print(a); Void Function(int value) class Bird{Fly Fly; // type is Fly a function with only one integer parameter Bird(this.fly); } typedef OnSuccessList<T>(List<T> banners); typedef OnSuccess<T>(T banners); typedef OnFail(String message);Copy the code