Flutter ● ○ ○

Kodebits Day 55: Named Parameters

Jul 10 2026
Practice named parameters with a short dart challenge.

What is the output?

void main() {
  int calc({
    required int a,
    int b = 2,
  }) {
    return a * b;
  }
  print(calc(a: 5));
}


Try it in the online Dart Playground →

[spoiler title="Solution"]

Answer:

10

Explanation:

Named parameters use names for clarity; b defaults to 2 when omitted.

[/spoiler]


Further Reading