Skip to content

Instantly share code, notes, and snippets.

@fvisticot
Last active December 24, 2019 17:38
Show Gist options
  • Save fvisticot/9047a6f2292d636d6ae7db979a18e87e to your computer and use it in GitHub Desktop.
Save fvisticot/9047a6f2292d636d6ae7db979a18e87e to your computer and use it in GitHub Desktop.
Completer
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