Created
April 9, 2025 17:51
-
-
Save icnahom/10b2caf1d9d5ca40fe0004721b6726f2 to your computer and use it in GitHub Desktop.
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
import 'package:async/async.dart'; | |
Future<void> main() async { | |
final operation = CancelableOperation.fromFuture(parentFuture()); | |
await Future.delayed(Duration(seconds: 2)); | |
await operation.cancel(); | |
print('canceled'); | |
} | |
parentFuture() async { | |
await childFuture(); | |
await childFuture(); | |
await childFuture(); | |
await childFuture(); | |
} | |
childFuture() async { | |
await Future.delayed(Duration(seconds: 2)); | |
print('executed'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment