{"id":3590,"date":"2022-05-20T11:06:50","date_gmt":"2022-05-20T11:06:50","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=3590"},"modified":"2022-05-20T11:06:50","modified_gmt":"2022-05-20T11:06:50","slug":"dart-if-statements","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/05\/20\/dart-if-statements\/","title":{"rendered":"Dart if Statements"},"content":{"rendered":"\n<p>If statement allows us to a block of code execute when the given condition returns true. In Dart programming, we have a scenario where we want to execute a block of code when it satisfies the given condition. The condition evaluates Boolean values TRUE or FALSE and the decision is made based on these Boolean values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dart If Statement Flow Diagram<\/h2>\n\n\n\n<p>The syntax of if statement is given below.<\/p>\n\n\n\n<p><strong>Syntax &#8211;<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>If (condition) {  \n     \/\/statement(s)  \n}  <\/code><\/pre>\n\n\n\n<p>The given condition is if statement will evaluate either TRUE or FALSE, if it evaluates true then statement inside if body is executed, if it evaluates false then statement outside if block is executed.<\/p>\n\n\n\n<p>Let&#8217;s understand the following example.<\/p>\n\n\n\n<p><strong>Example &#8211; 1<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main () {  \n  \/\/ define a variable which hold numeric value  \n var n = 35;  \n   \n \/\/ if statement check the given condition  \n if (n&lt;40){  \n    print(\"The number is smaller than 40\")  \n };  \n}  <\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The number is smaller than 40\n<\/code><\/pre>\n\n\n\n<p><strong>Explanation &#8211;<\/strong><\/p>\n\n\n\n<p>In the above program, we declared an integer variable n. We specified the condition in if statement. Is the given number is smaller than 40 or not? The if statement evaluated the true, it executed the if body and printed the result.<\/p>\n\n\n\n<p><strong>Example &#8211; 2<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main () {  \n  \/\/ define a variable which holds a numeric value  \n var age = 16;  \n  \n \/\/ if statement check the given condition  \n if (age>18){  \n    print(\"You are eligible for voting\");  \n };  \nprint(\"You are not eligible for voting\");   \n}  <\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-if-statements#\"><\/a><\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>You are not eligible for voting\n<\/code><\/pre>\n\n\n\n<p>In the above program, we can see that the if condition evaluated the false then execution skipped the if body and executed the outside statement of if block.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If statement allows us to a block of code execute when the given condition returns true. In Dart programming, we have a scenario where we want to execute a block of code when it satisfies the given condition. The condition evaluates Boolean values TRUE or FALSE and the decision is made based on these Boolean [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[916],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/3590"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=3590"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/3590\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=3590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=3590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=3590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}