While Loop
In while loop, the loop’s body will run until and unless the condition is true. You must write conditions first before statements. This loop checks conditions on every iteration. If the condition is true, the code inside {} is executed, if the condition is false, then the loop stops.
Syntax
while(condition){
//statement(s);
// Increment (++) or Decrement (--) Operation;
}
- If the condition is true, the code inside {} is executed.
Example
void main() {
var shots = 3;
int i = 1;
while (i <= shots) {
//executes three times
print('Shot: $shots');
i++;
}
print('jeet'); //execute onces
}