Last active
February 12, 2023 03:35
-
-
Save sergeykondr/b1b6b5f8e6fabf3b1fe24424674d7da0 to your computer and use it in GitHub Desktop.
microtask ex2
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'); | |
await 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
C running Future from B
C end of Future from B
sync C end from B
sync B end
sync C start from main
microtask from B !!!
C running Future from main
C end of Future from main
sync C end from main
sync D
microtask from main