# Programming in Dart: Functions & Closures

Jun 21 2022 · Dart 2.16, Flutter, DartPad

## Part 1: Meet the Function

### Episode complete

Play next episode

Next

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Functions are a great way to call code on demand. One convenient aspect of functions is that we can store them in variables and pass them around to other functions. In the second part of this course, you’ll see this in action. But for now, just know this is a great way to create dynamic and adaptable programs.

``````int multiply(int a, int b) {
return a * b;
}
``````
``````print(multiply(10, 10));
``````
``````var myFunction = print();
``````
``````var myFunction = multiply;
``````
``````void main() {
var scores = [54, 75, 32];
}
``````
``````int processScores(List<int> scores, Function processor) {

}
``````
``````int processScores(List<int> scores, Function processor) {
var total = 0;

}
``````
``````for (var score in scores) {
var number = processor(score, 2);
}
``````
``````total += number;
``````
``````total += (number is int) ? number : 0;
``````
``````int processScores(List<int> scores, int Function(int, int) processor) {
``````
``````for (var score in scores) {
total += processor(score, 2);
}
``````
``````void main() {
var scores = [54, 75, 32];
print(processScores(scores, multiply));
}
``````