Handle a missing delivery note
Before you start this intermediate track
Typed functions and maps. The lessons use named parameters and nullable values.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Understand it, then try it.
A nullable String can hold text or null. The ?? operator supplies a fallback only when its left side is null. Here a delivery label needs useful text even when no note was entered. A supplied note, including an empty string, would otherwise remain unchanged by this expression.
void main() { String? deliveryNote = null; final display = deliveryNote ?? 'Ring once'; print(display);}Each mission is a complete Dart 3 program with its own main function. Run one at a time with dart run. Only the built-in dart:core library is used; Flutter is not required.
Track the values line by line. Predict the result before running this example in your own editor.