Skip to content

Instantly share code, notes, and snippets.

@saeed-younus
Last active January 6, 2019 19:41
Show Gist options
  • Save saeed-younus/a193a3a8a5d977a88c5f4ff2bb277785 to your computer and use it in GitHub Desktop.
Save saeed-younus/a193a3a8a5d977a88c5f4ff2bb277785 to your computer and use it in GitHub Desktop.
Block async object
void main() async {
for (int i = 0; i < 5; i++) {
print('hello ${i + 1}');
}
BlockConstructor obj = new BlockConstructor();
await obj.ready;
print("After instantiate");
}
class BlockConstructor {
String a = "ABCD";
Future ready;
BlockConstructor() {
init();
print("Constructor");
}
void init() async {
print(10);
ready = new Future(() async {
await Future.delayed(Duration(milliseconds: 1000));
print("Delay");
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment