Flutter ● ● ○ Dart 3.6

Kodebits Day 32: Null-Aware Operator

May 31 2026
Practice null safety with a short dart challenge.

What does this print?

void main() {
  String? name;
  final result = name ?? 'Guest';
  print(result);
}


Try it in the online Dart Playground →

[spoiler title="Solution"]

Answer:

Guest

Explanation:

The ?? operator returns the right operand when the left is null.

[/spoiler]


Further Reading