Created
May 12, 2022 13:38
-
-
Save Chinecherem20199/2c110122c3afa9e20b5a017181d97de7 to your computer and use it in GitHub Desktop.
typedef_fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//typedef is a keyword | |
typedef Action = void Function(int); | |
void main() { | |
var values = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
var newVlues = <int>[]; | |
void Function(int) multiply5 = (value) => newVlues.add(value * 5); | |
listOperation(values, multiply5); | |
print(newVlues); | |
} | |
void listOperation(List<int> list, Action action) { | |
for (var item in list) { | |
action(item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment