Conditional Expression and Control Flow

Conditional expressions

Dart has two operators that let you concisely evaluate expressions that might otherwise require if-else statements:
1.condition ? expr1 : expr2
If condition is true, evaluates expr1 (and returns its value); otherwise, evaluates and returns the value of expr2.
2.expr1 ?? expr2
If expr1 is non-null, returns its value; otherwise, evaluates and returns the value of expr2.
When you need to assign a value based on a boolean expression, consider using ?:.

Comments

Popular posts from this blog

Flutter Widget 101 Part 1 (Basic of Flutters, Layouts, Rows and Columns)

Flutter Widget 101 Part 2 (List and Stack)

Animation Class: AppBar and Tabbar