Skip to content

Commit 1a4acde

Browse files
authored
Create prefer-iterable-in-flutter.dart
1 parent d1b07d7 commit 1a4acde

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}

0 commit comments

Comments
 (0)