A function is a named block of code you can call whenever you need it. Functions avoid repetition and make your code easier to read and maintain. Play 12 mini-games to master every part of Dart functions.
What is a function?
Functions let you name a block of code, call it whenever you need it, and pass in values (parameters) and get a result back (return value).
intadd(int a, int b) {
return a + b;
}
// call it:
print(add(3, 5)); // → 8
Parameters — values you pass in (like `a` and `b`)
Return type — the type of value the function gives back (`int`)
void — use this when the function doesn't return anything
Progress
0 / 12 mini-games solved
Stage 1
What is a function?
Pick the correct definition for a function in Dart.
Which statement best describes a function in Dart?