Created with <3 with dartpad.dev.
Created
March 20, 2023 13:13
-
-
Save futabooo/7f98f4460012b20122c1206803104d1e to your computer and use it in GitHub Desktop.
reverberating-clover-5211
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 { | |
final process = () async { | |
final delayed1 = await delayedNumber(1); | |
await delayedString('1').then((str) async { | |
final futures = [ | |
delayedNumber(2), | |
delayedNumber(3), | |
delayedNumber(4), | |
]; | |
await Future.wait(futures); | |
}); | |
print('finish delayedString'); | |
}; | |
await Future.wait<dynamic>( | |
[process(), Future<void>.delayed(Duration(seconds: 30))], | |
eagerError: true, | |
); | |
} | |
Future<int> delayedNumber(int number) async { | |
await Future.delayed(const Duration(seconds: 2)); | |
return number; | |
} | |
Future<String> delayedString(String str) async { | |
await Future.delayed(const Duration(seconds: 2)); | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment