Skip to content
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

✨Add custom onPicked callback when asset entity is generated #268

Merged
merged 5 commits into from
Sep 21, 2024

Conversation

yujune
Copy link
Contributor

@yujune yujune commented Aug 16, 2024

Context

Currently, when a picture or video is taken using the camera, the AssetEntity is retrieved via:

final assetEntity = await pickFromCamera(context);

This is achieved by calling Navigator.of(context).pop(entity);, which returns the AssetEntity to the previous screen.

However, this approach has a limitation when the CameraPicker widget is used in a scenario where it doesn't trigger a pop event, such as when the widget is part of a tab or a persistent page in a navigation stack. In these cases, there is no straightforward way to retrieve the captured AssetEntity.

Changes

  • Introduced a custom onPicked callback that directly provides the generated AssetEntity without relying on the Navigator.of(context).pop(entity);.

@yujune yujune requested a review from AlexV525 as a code owner August 16, 2024 06:57
Copy link
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is good, I'd prefer onPickConfirmed for better readability.

lib/src/states/camera_picker_state.dart Outdated Show resolved Hide resolved
Copy link
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following up all suggestions!

@AlexV525 AlexV525 merged commit 77f32bc into fluttercandies:main Sep 21, 2024
5 checks passed
@AlexV525
Copy link
Member

@all-contributors Add @yujune for code

Copy link
Contributor

@AlexV525

I've put up a pull request to add @yujune! 🎉

AlexV525 pushed a commit that referenced this pull request Sep 21, 2024
Adds @yujune as a contributor for code.

This was requested by AlexV525 [in this
comment](#268 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants