Last active
January 6, 2019 19:41
-
-
Save saeed-younus/a193a3a8a5d977a88c5f4ff2bb277785 to your computer and use it in GitHub Desktop.
Block async object
This file contains hidden or 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
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