Cover image for Else if Ladder Statement in Dart

Else if Ladder Statement in Dart

jay_tillu profile image Jay Tillu😎 ・2 min read

Else if ladder is a type of conditionals in the dart. Just like if and if-else. We use else if ladder when we want to check multiple conditions.


if (boolean_expression) {
  //Statements to be executed if the condition is true
} else if (boolean_expression) {
  //Statements to be executed if the condition is true
} else if (boolean_expression) {
  //Statements to be executed if the condition is true
} else {
  //Statements to be executed if all the conditions are false
  • If the Boolean expression evaluates to be true, then the block of code inside the if statement will be executed. Otherwise, the compiler will check else-if’s condition.

  • Once any else-if’s condition is true, then all other else-if conditions will be skipped. So every else-if condition must be unique.

  • If all the else-if conditions evaluate to be false, then the else’s code block will be executed.

  • Here again, the else is optional. But if it occurs then it must be after all the else-if blocks.

Sample Code

void main() {
  int number = 2;

  if (number == 5) {
    print("Number is 5");
  } else if (number == 1) {
    print("Number is 1");
  } else if (number == 2) {
    print("Number is 2");
  } else {
    print("None of the number is matched");

Number is 2

That’s all for else if ladder statement guys. Feel free to share me if I miss something. I’ll love to learn it from you. Till Then Keep Loving, Keep Coding. I’ll surely catch you up in the next article.

Remember no teacher, no book, no video tutorial, or no blog can teach you everything. As one said Learning is Journey and Journey never ends. Just collect some data from here and there, read it, learn it, practice it, and try to apply it. Don’t feel hesitate that you can’t do that or you don’t know this concept or that concept. Remember every programmer was passed from the path on which you are walking right now. Remember Every Master was Once a Beginner. Work hard and Give your best.

For More Information Please Visit Following Links

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊
or just mail me at jayviveki13@gmail.com

Posted on by:

jay_tillu profile

Jay Tillu😎


🌏 विधायास्य धमॅस्य संरक्षणम् 🌍 ☀️ Society before Self ☀️ 🙏🏻 Humanism by Religion 🙏🏻 💻 Work for Mankind 💻 🌐 Believes in वसुधैव कुटुम्बकम् 🌐


Editor guide