Dart by Example: Function Types
1. typedef bool Validator(int n);
3. bool positive(int n) => n >= 0;
4. bool lessThan100(int n) => n < 100;
6. bool bothValid(int n, Validator v1, Validator v2) {
7. return v1(n) && v2(n);
8. }
10. main() {
11. Validator both = (int n) => bothValid(n, positive, lessThan100);
12. print('${both(5)}');
13. print('${both(1000)}');
14. }
1. $ dart typedef.dart
2. true
3. false
