Dart Conditional Operators

In this tutorial you will learn about the Dart Conditional Operators and its application with practical example.

Dart Conditional Operators ( ? : )

The conditional operator is considered as short hand for if-else statement. Conditional operator is also called as “Ternary Operator”.

Syntax 1:-

If condition is true the expression will return expr1, if it is not it will return expr2.

Example:-

Output:-

Syntax 2:-

If expr1 is non-null, returns its value; otherwise, evaluates and returns the value of expr2.

Example:-

Output:-

Recommended:-  Dart Numbers
In this tutorial we have learn about the Dart Conditional Operators and its application with practical example. I hope you will like this tutorial.