Last active
December 24, 2019 17:38
-
-
Save fvisticot/9047a6f2292d636d6ae7db979a18e87e to your computer and use it in GitHub Desktop.
Completer
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
import 'dart:async'; | |
void main() async{ | |
Future<int>testTimer(int i) { | |
final completer=Completer<int>(); | |
Timer(Duration(seconds: 5), () { | |
print("coucou from :$i"); | |
if (i != 3) | |
completer.complete(i); | |
}); | |
return completer.future; | |
} | |
for (int i = 0; i < 5; i++) { | |
await testTimer(i); | |
print("i: $i"); | |
} | |
print("Fin"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment