Google News
logo
Flutter - Interview Questions
Explain the difference between
?? operator ? Operator
The "??" operator is used to evaluate and returns the value between two expressions. It can be used as below :
expr1 ?? expr2

This operator first checks the expression 1 and, if it is non-null, returns its value; otherwise, it will evaluate and returns the value of expression 2.
The "?" operator is used to evaluate and returns the value between two expressions based on the given condition. It can be used as below :
condition ? expr1 : expr2

This operator first checks the condition, and if it is true, it will evaluate expr1 and returns its value (if the condition is matched). Otherwise, it evaluates and returns the value of expr2.
Advertisement