Atom

Short-circuiting and null access

Avoid looking up a field on an absent value

Use optional access for the field and a fallback for the result.

Atom
settings = null
print(settings?.theme ?? 'light')
Output
light

The optional access yields null, which triggers the fallback.

Prefix not takes an operand that includes equality and comparison. The and and or operators short-circuit and return the selected operand. Null fallback evaluates its right operand only when the left operand is null. Optional member access returns null for a null receiver.