-
Notifications
You must be signed in to change notification settings - Fork 368
feat: Add cancel token for darwin #1234
New issue
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
Conversation
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
# Conflicts: # CHANGELOG.md # pubspec.yaml
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md # pubspec.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds cancel token functionality for Darwin platforms (iOS/macOS), allowing users to cancel ongoing asset loading operations. The implementation introduces a PMCancelToken class and integrates it throughout the asset loading pipeline.
Key changes:
- Introduces
PMCancelTokenclass for managing cancellation requests - Adds
cancelTokenparameters to various asset loading methods - Implements platform-specific cancellation handling for iOS/macOS
- Makes previously private methods public (
getFile,getOriginBytes)
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/types/cancel_token.dart | New file implementing the PMCancelToken class |
| lib/src/types/entity.dart | Adds cancel token support to asset loading methods and makes some methods public |
| lib/src/managers/photo_manager.dart | Adds static methods for cancelling requests |
| lib/src/internal/plugin.dart | Implements cancel token handling and method channel modifications |
| lib/src/internal/enums.dart | Adds cancel state to PMRequestState enum |
| lib/src/internal/constants.dart | Adds cancel-related constants |
| lib/photo_manager.dart | Exports the new cancel token class |
| ios/Classes/core/PMManager.m | Implements iOS cancellation logic and request tracking |
| ios/Classes/core/PMManager.h | Updates method signatures for cancel token support |
| ios/Classes/PMResultHandler.m | Adds cancel token retrieval method |
| ios/Classes/PMResultHandler.h | Updates interface to support cancel token functionality |
| ios/Classes/PMPlugin.m | Integrates cancel token handling into plugin methods |
| README.md | Documents the new cancel functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
lib/src/types/cancel_token.dart
Outdated
| /// [PhotoManagerPlugin.cancelRequest]. | ||
| /// User don't need to use this. | ||
| @nonVirtual | ||
| String get key => _index.toString(); |
Copilot
AI
Oct 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key getter returns _index.toString() but should return index.toString(). This will always return '0' since _index is a static variable that gets incremented but the getter references the class-level static variable instead of the instance variable.
| String get key => _index.toString(); | |
| String get key => index.toString(); |
lib/src/types/entity.dart
Outdated
| Future<typed_data.Uint8List?> _getOriginBytes({ | ||
| /// Obtain the raw data of the asset. | ||
| /// | ||
| /// **Use it with cautious** since the original data might be epic large. |
Copilot
AI
Oct 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'cautious' to 'caution'.
| /// **Use it with cautious** since the original data might be epic large. | |
| /// **Use it with caution** since the original data might be epic large. |
|
I have forked this repository to add some features like getAssetsGrouped. I don't know exactly what is causing the problem, but it's definitely somewhere in this PR |
|
@HenrikH96 This seems to be related to #1262 |
Signed-off-by: Caijinglong [email protected]