Created
October 24, 2019 08:21
-
-
Save ipondroid/1f8e3e43f8f45b79853502ed5eaece79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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