Typedef in Dart.
Hello everybody, in this post, we'll see what typedef is and how use it in Dart.
We suppose we need to concat two string with a special characters. Notice the problem is very simple in order to explain what typedef is.
So, this is a typedef:
Typedefs are alias for functions which are object. So, Typedefs are object with an alias =).
So far, so good. Now, we need to implement a function which has same signature, i mean: (String, String) => (String) in our case. I mean given two params String then output will be another String . i.e:
We need to use our typedef Join and ours functions in a joinWith new function:
Finally, we use our typedef:
You can test this code running on console:
dart main.dart
Enjoy!