Dart Control Flow Statement

The control statements or flow of control statements are used to control the flow of Dart program. These statements are very important in any programming languages to decide whether other statement will be executed or not. The code statement generally runs in the sequential manner. We may require executing or skipping some group of statements based on the given condition, jumps to another statement, or repeat the execution of the statements.

In Dart, control statement allows to smooth flow of the program. By using the control flow statements, a Dart program can be altered, redirected, or repeated based on the application logic.

Categories of Flow Statement

In Dart, Control flow statement can be categorized mainly in three following ways.

  • Decision-making statements
  • Looping statements
  • Jump statements

Dart Decision-Making Statements

The Decision-making statements allow us to determine which statement to execute based on the test expression at runtime. Decision-making statements are also known as the Selection statements. In Dart program, single or multiple test expression (or condition) can be existed, which evaluates Boolean TRUE and FALSE. These results of the expression/condition helps to decide which block of statement (s) will execute if the given condition is TRUE or FALSE.

Dart Control Flow Statement

Dart provides following types of Decision-making statement.

  • If Statement
  • If-else Statements
  • If else if Statement
  • Switch Case Statement

Dart Looping Statements

Dart looping statements are used to execute the block of code multiple-times for the given number of time until it matches the given condition. These statements are also called Iteration statement.

Dart provides following types of the looping statements.

  • Dart for loop
  • Dart for….in loop
  • Dart while loop
  • Dart do while loop

Dart Jump Statements

Jump statements are used to jump from another statement, or we can say that it transfers the execution to another statement from the current statement.

Dart provides following types of jump statements -

  • Dart Break Statement
  • Dart Continue Statement

The above jump statements behave differently.