In this tutorial you will learn about the Dart Control Flow Statements and its application with practical example.
Dart Control Flow Statements
Control flow or flow of control is the order in which instructions, statements and function calls being executed or evaluated when a program is running. The control flow statements are also called as Flow Control Statements. In Dart, statements inside your code are generally executed sequentially from top to bottom, in the order that they appear. It is not always the case your program statements to be executed straightforward one after another sequentially, you may require to execute or skip certain set of instructions based on condition, jump to another statements, or execute a set of statements repeatedly. In Dart, control flow statements are used to alter, redirect, or to control the flow of program execution based on the application logic.
Dart Control Flow Statement Types
In Dart, Control flow statements are mainly categorized in following types –
Dart Selection Statements
In Dart, Selection statements allow you to control the flow of the program during run time on the basis of the outcome of an expression or state of a variable. Selection statements are also referred to as Decision making statements. Selection statements evaluates single or multiple test expressions which results in “TRUE” or “FALSE”. The outcome of the test expression/condition helps to determine which block of statement(s) to executed if the condition is “TRUE” or “FALSE” otherwise.
In Dart, we have following selection statements –
Dart Iteration Statements
In Dart, Iteration statements are used to execute the block of code repeatedly for a specified number of times or until it meets a specified condition. Iteration statements are commonly known as loops or looping statements.
In Dart, we have following iteration statements available-
Dart Jump Statements
Jump statements are used to alter or transfer the control to other section or statements in your program from the current section.
In Dart, we have following types of jump statements –
All of the above jump statements cause different types of jumps.