The break and continue statement
Let’s learn how to have more control over loops using the break and continue statements.
The break
Statement
The break
is used for prematurely stopping a loop.
When Dart finds a break
statement, it breaks from the loop regardless of whether the iterations have been completed or not.
It’s mostly used with a conditional statement. Based on the condition, the loop will either need to exit or not.
Let’s look at an example similar to the one we looked at with for-loops, where we have a ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy