{"id":1940,"date":"2022-04-07T06:14:29","date_gmt":"2022-04-07T06:14:29","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1940"},"modified":"2022-04-07T06:14:29","modified_gmt":"2022-04-07T06:14:29","slug":"decision-making-and-loops","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/04\/07\/decision-making-and-loops\/","title":{"rendered":"Decision Making and Loops"},"content":{"rendered":"\n<p>The decision-making is a feature that allows you to evaluate a condition before the instructions are executed. The Dart language supports the following types of decision-making statements:<\/p>\n\n\n\n<ul><li>If statement<\/li><li>If-else statement<\/li><li>Switch statement<\/li><\/ul>\n\n\n\n<p>The below diagram explains it more clearly.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/flutter\/images\/flutter-dart-programming.png\" alt=\"What is Dart Programming\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main() {   \n   var num = 12;   \n   if (num % 2 = = 0) {   \n      print(\"Number is Even.\");   \n   } else {   \n      print(\"Number is Odd.\");   \n   }   \n}  <\/code><\/pre>\n\n\n\n<p><strong>Loops<\/strong>&nbsp;are used to execute a block of code repeatedly until a specified condition becomes true. Dart language supports the following types of loop statements:<\/p>\n\n\n\n<ul><li>for<\/li><li>for..in<\/li><li>while<\/li><li>do..while<\/li><\/ul>\n\n\n\n<p>The below diagram explains it more clearly.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/flutter\/images\/flutter-dart-programming2.png\" alt=\"What is Dart Programming\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main() {   \n   var name = &#91;\"Peter\", \"Rinky Ponting\", \"Abhishek\"];   \n     \n   for (var prop in name) {   \n      print(prop);   \n   }   \n}  <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Comments<\/h2>\n\n\n\n<p>Comments are the lines of&nbsp;<strong>non-executable<\/strong>&nbsp;code. They are one of the main aspects of all programming languages. The purpose of this is to provide information about the project, variable, or an operation. There are three types of comments in Dart programming:<\/p>\n\n\n\n<ul><li><strong>Make format comments:<\/strong>&nbsp;It is a single line comment (\/\/)<\/li><li><strong>Block Comments:<\/strong>&nbsp;It is a multi-line comment (\/*&#8230;*\/)<\/li><li><strong>Doc Comments:<\/strong>&nbsp;It is a document comment that used for member and types (\/\/\/)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Continue and Break<\/h2>\n\n\n\n<p>Dart has also used the continue and break keyword in the loop, and elsewhere it required. The continue statement allows you to skip the remaining code inside the loop and immediately jump to the next iteration of the loop. We can understand it from the following example.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>void main() {   \n  for(int i=1;i&lt;=10;i++){    \n    if(i==5){    \n      print(\"Hello\");  \n      continue; \/\/it will skip the rest statement        \n    }    \n    print(i);    \n  }   \n}  <\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><\/p>\n\n\n\n<p>The&nbsp;<strong>break<\/strong>&nbsp;statement allows you to terminate or stops the current flow of a program and continues execution after the body of the loop. The following example gives a detailed explanation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>void main() {   \n  for(int i=1;i&lt;=10;i++){    \n    if(i==5){    \n      print(\"Hello\");  \n      break;\/\/it will terminate the rest statement        \n    }    \n    print(i);    \n  }   \n}  <\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The decision-making is a feature that allows you to evaluate a condition before the instructions are executed. The Dart language supports the following types of decision-making statements: If statement If-else statement Switch statement The below diagram explains it more clearly. Example Loops&nbsp;are used to execute a block of code repeatedly until a specified condition becomes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[659],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1940"}],"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=1940"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1940\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}