Last active
February 12, 2023 03:34
-
-
Save sergeykondr/d609f8a545cd9f6a559daf03906dac14 to your computer and use it in GitHub Desktop.
microtask ex 1
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
void main() async { | |
methodA(); | |
await methodB(); | |
await methodC('main'); | |
methodD(); | |
} | |
void methodA(){ | |
print('sync A'); | |
} | |
Future<void> methodB() async { | |
print('sync B start'); | |
await methodC('B'); | |
print('sync B end'); | |
} | |
Future<void> methodC(String from) async { | |
print('sync C start from $from'); | |
Future(() { | |
print('C running Future from $from'); | |
}).then((_){ | |
print('C end of Future from $from'); | |
}); | |
Future.microtask(() => print('microtask from $from')); | |
print('sync C end from $from'); | |
} | |
void methodD(){ | |
print('sync D'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sync A
sync B start
sync C start from B
sync C end from B
microtask from B
sync B end
sync C start from main
sync C end from main
microtask from main
sync D
C running Future from B
C end of Future from B
C running Future from main
C end of Future from main