?.) accesses a property or invokes a method on a receiver only if that receiver is non-null. If the receiver is null, the expression short-circuits and evaluates to null immediately, bypassing the member access.
Syntax
Operational Semantics
The evaluation of the expressiona?.b proceeds as follows:
- Evaluation of Operand: The left-hand operand (
a) is evaluated. - Null Check:
- If
aisnull, the evaluation stops (short-circuits). The value of the entire expression isnull. - If
ais notnull, the member access (.b) is executed on the object.
- If
- Result: The expression returns either the value of
bornull.
Type Implications
The return type of a conditional access expression is always the nullable version of the accessed member’s type. If a memberb has a return type of T, the expression a?.b has a static type of T?. This applies even if T is already nullable; the resulting type remains T? (nullable types are idempotent).
Chaining
The operator can be chained to safely traverse deep object structures. If any link in the chain evaluates tonull, the remainder of the chain is skipped, and the entire expression evaluates to null.
Master Dart with Deep Grasping Methodology!Learn More





