Skip to content

Instantly share code, notes, and snippets.

@ipondroid
Created October 24, 2019 08:21
Show Gist options
  • Save ipondroid/1f8e3e43f8f45b79853502ed5eaece79 to your computer and use it in GitHub Desktop.
Save ipondroid/1f8e3e43f8f45b79853502ed5eaece79 to your computer and use it in GitHub Desktop.
void future_dowhile() {
final nums = [1, 2, 3, 4, 5];
var sum = 0;
var count = 0;
Future.doWhile(() {
print('count:$count');
if (count == nums.length) {
return false;
} else {
sum += nums[count];
count++;
return true;
}
});
print('sum:$sum');
}
// output
// count:0
// count:1
// count:2
// count:3
// count:4
// count:5
// sum:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment