- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Break statement in Dart Programming
The break statement is used when we want to break or terminate the execution of a loop. Once the break statement is reached the control is transferred from the current loop to whatever is written after the loop.
It is mostly used in the conditional statement and also in loops of all types. It is present in almost all popular programming languages.
Syntax
break;
Now let's take a very simple example, where we have a variable named num and we are iterating until num > 5. Suppose we want to exit from the loop when we know that the value inside the num variable has become 6, we can do that with the help of the break statement.
Example
Consider the example shown below −
void main(){ var num = 10; while(num > 5){ if(num == 6){ print("Number became 6, so braking."); break; } num--; } print("Now, num should be 6 : ${num}"); }
Output
Number became 6, so braking. Now, num should be 6 : 6
Example
Let's take one more example, where we make use of the for-in loop.
Consider the example shown below −
void main(){ var name = "apple"; var fruits = ["mango","banana","litchi","apple","kiwi"]; for(var fruit in fruits){ if(fruit == name){ print("Don't need an apple!"); break; } } print("After the break, this should be printed!"); }
Output
Don't need an apple! After the break, this should be printed!
- Related Articles
- Continue statement in Dart Programming
- Return statement in Dart Programming
- Break statement in Lua Programming
- Comments in Dart Programming
- Constructors in Dart Programming
- Enumerations in Dart Programming
- Functions in Dart Programming
- Immutability in Dart Programming
- Inheritance in Dart Programming
- Iterables in Dart Programming
- Lists in Dart Programming
- Loops in Dart Programming
- Maps in Dart Programming
- Methods in Dart Programming
- Mixins in Dart Programming

Advertisements