Skip to content

Commit

Permalink
Rename onPick to onPickConfirmed.
Browse files Browse the repository at this point in the history
  • Loading branch information
yujunetee committed Sep 9, 2024
1 parent a499379 commit e9dd2a5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ final AssetEntity? entity = await CameraPicker.pickFromCamera(
| onError | `CameraErrorHandler?` | 拍摄照片过程中的自定义错误处理 | null |
| onXFileCaptured | `XFileCapturedCallback?` | 拍摄文件生成后的回调 | null |
| onMinimumRecordDurationNotMet | `VoidCallback?` | 录制时长未达到最小时长时的回调方法 | null |
| onPicked | `Function(AssetEntity)?` | 拍照或录像确认时的回调方法。 | null |
| onPickConfirmed | `void Function(AssetEntity)?` | 拍照或录像确认时的回调方法。 | null |

### 使用自定义的 `State`

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Fields in `CameraPickerConfig`:
| onError | `CameraErrorHandler?` | The error handler when any error occurred during the picking process. | null |
| onXFileCaptured | `XFileCapturedCallback?` | The callback type definition when the XFile is captured by the camera. | null |
| onMinimumRecordDurationNotMet | `VoidCallback?` | The callback when the recording is not met the minimum recording duration. | null |
| onPicked | `Function(AssetEntity)?` | The callback when picture is taken or video is confirmed. | null |
| onPickConfirmed | `void Function(AssetEntity)?` | The callback when picture is taken or video is confirmed. | null |

### Using custom `State`s

Expand Down
4 changes: 2 additions & 2 deletions lib/src/constants/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class CameraPickerConfig {
this.onError,
this.onXFileCaptured,
this.onMinimumRecordDurationNotMet,
this.onPicked,
this.onPickConfirmed,
}) : assert(
enableRecording == true || onlyEnableRecording != true,
'Recording mode error.',
Expand Down Expand Up @@ -170,5 +170,5 @@ final class CameraPickerConfig {

/// The callback when picture is taken or video is confirmed.
/// 拍照或录像确认时的回调方法。
final AssetEntity Function(AssetEntity)? onPicked;
final void Function(AssetEntity)? onPickConfirmed;
}
8 changes: 4 additions & 4 deletions lib/src/states/camera_picker_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,9 @@ class CameraPickerState extends State<CameraPicker>
viewType: CameraPickerViewType.image,
);
if (entity != null) {
if (pickerConfig.onPicked case final onPicked?) {
if (pickerConfig.onPickConfirmed case final onPickConfirmed?) {
await controller.resumePreview();
onPicked(entity);
onPickConfirmed(entity);
} else {
Navigator.of(context).pop(entity);
}
Expand Down Expand Up @@ -1061,9 +1061,9 @@ class CameraPickerState extends State<CameraPicker>
viewType: CameraPickerViewType.video,
);
if (entity != null) {
if (pickerConfig.onPicked case final onPicked?) {
if (pickerConfig.onPickConfirmed case final onPickConfirmed?) {
await controller.resumePreview();
onPicked(entity);
onPickConfirmed(entity);
} else {
Navigator.of(context).pop(entity);
}
Expand Down

0 comments on commit e9dd2a5

Please sign in to comment.