Warning: Undefined array key "lang_code" in /home/pmfnldmy/public_html/androidatc/ap/extension/classes/common.php on line 800
Dart Programming - IF Statement

IF Statement

The "if" statement is a programming conditional statement that, if proved true, executes the second part of the statement. Otherwise, if proved false, the program will skip the execution of the second part and do something else.

Example:
In the following example, the Dart compiler will consider the "if" condition and the statement highlighted in grey color in this example as one block. if x>5 (true) the program will print a hello message, and if it is not (false), the program will continue to perform the next action.

main() {
 int x=10;

 if(x>5){

   print("Hello, I am If statement running now ......");

 }
 print('The End');

  }


The run result of this code follows:

IF Statment - Dart Programming

If you change the program as follows:

main() {

 int x=2;

 if(x>5){

   print("Hello, I am If statement running now ......");
 }
 print('The End');

  }


The run result of this code follows:

Dart Programming IF Statment - Flutter Development

* This topic is a part of lesson 2 of Flutter Application Development course. For more information about this course, click here.