Instructor: Control flow statements are possible with Dart in the following forms. A nest statement allows us to evaluate a condition and decide what to do depending on its outcome.
The else block is optional, which reflects behavior similar across most programming languages. The condition we are evaluating must explicitly result to a Boolean value, else an error is thrown.
You can also chain your if statements. You can write the statement in its short form using the ternary operator. Dart support various for loops with a familiar syntax.
We can also capture the values of the current loop index inside a closure. When working with iterable types like list and set, you can use the for each method to loop over its items.
You could also use a for loop for iterable types. The while loop can be used as an alternate form of the for loop. Use a dual loop to ensure that a print logic runs at least once. Use a break statement to stop a running loop. Use continue to skip the current loop iteration.
Use switch and case statements for comparing integers, strings, and compile time constant values. Here, the break statement stops further execution of the switch statement. Omitting the break will give you an error unless you are following through to the next block within the sequence.
Use an assert to disrupt code execution if the given condition evaluates the false. Parse a string as the second argument to attach a message to the assert. This concludes the lesson.