File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
tipsandtricks/prefer-iterable-in-flutter Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ // 🐦 Twitter https://twitter.com/vandadnp
2
+ // 🔵 LinkedIn https://linkedin.com/in/vandadnp
3
+ // 🎥 YouTube https://youtube.com/c/vandadnp
4
+ // 💙 Free Flutter Course https://linktr.ee/vandadnp
5
+ // 📦 11+ Hours Bloc Course https://youtu.be/Mn254cnduOY
6
+ // 🔶 7+ Hours MobX Course https://youtu.be/7Od55PBxYkI
7
+ // 🦄 8+ Hours RxSwift Coursde https://youtu.be/xBFWMYmm9ro
8
+ // 🤝 Want to support my work? https://buymeacoffee.com/vandad
9
+
10
+ Future <int > doHeavyComputation (int index) => Future .delayed (
11
+ const Duration (seconds: 1 ),
12
+ () {
13
+ 'Iteration ${index + 1 }' .log ();
14
+ return index;
15
+ },
16
+ );
17
+
18
+ Future <void > testIt () async {
19
+ for (final future in Iterable .generate (10 )
20
+ .map (
21
+ (index) => doHeavyComputation (
22
+ index,
23
+ ),
24
+ )
25
+ .take (2 )) {
26
+ final result = await future;
27
+ result.log ();
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments