[Flutter]
[Flutter] Future / async 예제 메모2
Hevton
2022. 3. 12. 19:16
반응형
Future<String> fu() {
return Future.delayed(Duration(seconds: 2), () {
print('SUCCESS');
return 'STR';
});
}
Future<String> hi() async {
fu().then((e) {print(e);});
return 'CLEAR';
}
void runFunc() async {
final f = await hi();
print(f);
print('WAIT');
}
void main() {
runFunc();
}
CLEAR
WAIT
2초후
SUCCESS
STR
then은 안기다림.
반응형