We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dio
5.3.3
MacOS
flutter doctor -v
[✓] Flutter (Channel stable, 3.13.9, on macOS 14.1.1 23B81 darwin-arm64, locale zh-Hans-CN) • Flutter version 3.13.9 on channel stable at /Users/tom/Library/Flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision d211f42860 (2 weeks ago), 2023-10-25 13:42:25 -0700 • Engine revision 0545f8705d • Dart version 3.1.5 • DevTools version 2.25.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) • Android SDK at /Users/tom/Library/Android/sdk • Platform android-33, build-tools 33.0.2 • ANDROID_HOME = /Users/tom/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) • All Android licenses accepted. [!] Xcode - develop for iOS and macOS (Xcode 15.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A240d ✗ Unable to get list of installed Simulator runtimes. • CocoaPods version 1.12.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.84.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.76.0 [✓] Connected device (3 available) • Pixel 4 (mobile) • 98111FFAZ000UV • android-arm64 • Android 13 (API 33) • macOS (desktop) • macos • darwin-arm64 • macOS 14.1.1 23B81 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.123 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category.
No response
import 'package:dio/dio.dart'; import 'package:path/path.dart' as p; import 'dart:io'; // https://pub.dev/packages/dio#cancellation final cancelToken = CancelToken(); void main(List<String> arguments) async { download(); Future.delayed(Duration(seconds: 2)).then((value) { cancel(); }); } download() async { final dio = Dio(); final url = "https://www.example.com/picture.png"; // For example final savePath = p.join(Directory.current.path, "picture.png"); try { await dio.downloadUri( Uri.parse(url), savePath, cancelToken: cancelToken, onReceiveProgress: (int count, int total) async { print("Received $count, Total received: $total"); }, ); } catch (e) { print("Error: $e"); } } cancel() { try { cancelToken.cancel(); // Not an async method } catch (e) { print("$e"); } }
Cancellation exception caught
Cancellation exception not caught
The text was updated successfully, but these errors were encountered:
CancelToken
ResponseType.stream
Duplicate of #1869
Sorry, something went wrong.
No branches or pull requests
Package
dio
Version
5.3.3
Operating-System
MacOS
Output of
flutter doctor -v
Dart Version
No response
Steps to Reproduce
Expected Result
Cancellation exception caught
Actual Result
Cancellation exception not caught
The text was updated successfully, but these errors were encountered: