Dart Conditional Expressions:
Jinali Ghoghari
1 min read
Table of contents
1. ( condition ? expr1 : expr2)
:
The conditional operator evaluates the condition and returns one of two expressions based on whether the condition is true or false.
If the condition is true,
expr1
is evaluated and returned; otherwise,expr2
is evaluated and returned.
2. (expr1 ?? expr2)
: (null aware)
- The null-aware conditional operator evaluates
expr1
. Ifexpr1
is non-null, its value is returned; otherwise,expr2
is evaluated and returned.
0
Subscribe to my newsletter
Read articles from Jinali Ghoghari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by