Most of the people, who have programmed in C programming language, are aware of goto and label statements which are used to jump from one point to other but unlike Java, Dart also doesn’t have any goto statements but indeed it has labels which can be used with continue and break statements and help them to take a bigger leap in the code.
It must be noted that line-breaks are not allowed between ‘label-name’ and loop control statements.
Example #1: Using label with the break statement
You are inside the loop Geek
The above code results into only one-time printing of statement because once the loop is broken it doesn’t go back into it.
Example #2: Using label with the continue statement
You are inside the loop Geek You are inside the loop Geek You are still inside the loop
The above code results in printing of the statement twice because of the condition it didn’t break out of the loop and thus printing it twice.
- How to Combine Lists in Dart?
- Basics of Numbers in Dart
- Dart - Super and This keyword
- Dart - Standard Input Output
- Generators in Dart
- Dart - Classes And Objects
- Operators in Dart
- Dart - Loops
- Switch Case in Dart
- Dart - Loop Control Statements (Break and Continue)
- Dart Programming - Functions
- Instance and class methods in Dart
- Abstract Classes in Dart
- Dart Programming - List
- Different Types of Functions in Dart
- Dart - Splitting of String
- Method Overriding in Dart
- Concept of Isolates in Dart
- Concept of Callable Classes in Dart
- Getter and Setter Methods in Dart
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.