if…else Statement
This type of statement simply checks the condition and if it is true, the statements within are executed but if not then else statements are executed.
Syntax:
if ( condition ){
// body of if
}
else {
// body of else
}
Illustration with Image:
Example:
void main()
{
int gfg = 10;
// Condition is false
if (gfg > 30) {
// This will not be printed
print("Condition is true");
}
else {
// This will be printed
print("Condition id false");
}
}
Output:
Condition is false
Dart Programming – If Else Statement (if , if..else, Nested if, if-else-if)
Decision-making statements are those statements that allow the programmers to decide which statement should run in different conditions.
There are four ways to achieve this:
- if Statement
- if-else Statement
- else-if Ladder
- Nested if Statement