DEV Community

Cover image for If Statement in Dart
Jay Tillu😎
Jay Tillu😎

Posted on • Updated on

If Statement in Dart

If is a conditional statement. It used when we just want to check the condition. Let’s see if’s syntax and some rules.

Syntax


if (boolean_expression) {
    //Statements to be executed if the condition is true
}
Enter fullscreen mode Exit fullscreen mode
  • If the Boolean expression evaluates to be true, then the block of code inside the if statement will be executed.

  • If the Boolean expression evaluates to be false, then the first set of code after the end of the if statement (after the closing curly brace) will be executed.

Sample Code

void main() {
  int number = 35;
  if (number > 5) {
    print("Number is greater than 5");
  }
}

Output
Number is greater than 5
Enter fullscreen mode Exit fullscreen mode

That’s it for if statement guys. I know if you are pro-programmer then it seems too much basics for you. But guys I create this series for beginners and I add details keeping them in mind. So if you are pro-programmers please check my other articles.

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 another 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

Jai Hind, Vande Mataram 🇮🇳

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊

Top comments (0)