Closed laeo closed 11 months ago
Many thanks to your work, but i'v found the code below
void updateSelection(List<MediaViewModel> selectedMediaList) { if (widget.mediaCount == MediaCount.multiple) { setState(() { _selectedMedia = selectedMediaList; }); } else if (selectedMediaList.length == 1) { widget.onDone(selectedMediaList); } }
When user selected a photo, it will auto call onPicked callback, its weird, user should to confirm their choice.
Can you update the logic to ensure the onPicked callback only calls if
completeSelection
called.
@laeo , Thank you so much for the appreciation. Please let me be clear about the issue. Are you talking about single selection mode? Usually users just select the picture and it's done. Maybe you have a requirement where user can change the mode from single to multiple. I would like to ask isn't multiple picking mode solving your issue?
Many thanks to your work, but i'v found the code below
void updateSelection(List<MediaViewModel> selectedMediaList) { if (widget.mediaCount == MediaCount.multiple) { setState(() { _selectedMedia = selectedMediaList; }); } else if (selectedMediaList.length == 1) { widget.onDone(selectedMediaList); } }
When user selected a photo, it will auto call onPicked callback, its weird, user should to confirm their choice. Can you update the logic to ensure the onPicked callback only calls if
completeSelection
called.@laeo , Thank you so much for the appreciation. Please let me be clear about the issue. Are you talking about single selection mode? Usually users just select the picture and it's done. Maybe you have a requirement where user can change the mode from single to multiple. I would like to ask isn't multiple picking mode solving your issue?
Yes, i'm talking about single selection mode.
I think it may better to use completeSelection
callback to control when the selection is done. Force call onDone()
when user just selected a photo is not a good idea.
Maybe provide completeSelection
to onPicking()
callback is more better way.
MediaPicker(
onPicking: (List<Media> selected, VoidCallback completeSelection) {
if (selected.length == 1) completeSelection();
},
);
Many thanks to your work, but i'v found the code below
When user selected a photo, it will auto call onPicked callback, its weird, user should to confirm their choice.
Can you update the logic to ensure the onPicked callback only calls if
completeSelection
called.