From e9dd2a5fe641099f01ac9dcc8c7714ef1c2d68b1 Mon Sep 17 00:00:00 2001 From: yujune Date: Mon, 9 Sep 2024 10:28:46 +0800 Subject: [PATCH] Rename onPick to onPickConfirmed. --- README-ZH.md | 2 +- README.md | 2 +- lib/src/constants/config.dart | 4 ++-- lib/src/states/camera_picker_state.dart | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README-ZH.md b/README-ZH.md index c27779c..24cf247 100644 --- a/README-ZH.md +++ b/README-ZH.md @@ -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` diff --git a/README.md b/README.md index b62921e..91c7db2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/src/constants/config.dart b/lib/src/constants/config.dart index 13c8be9..fd176a8 100644 --- a/lib/src/constants/config.dart +++ b/lib/src/constants/config.dart @@ -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.', @@ -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; } diff --git a/lib/src/states/camera_picker_state.dart b/lib/src/states/camera_picker_state.dart index e0e44dc..f24cf5d 100644 --- a/lib/src/states/camera_picker_state.dart +++ b/lib/src/states/camera_picker_state.dart @@ -926,9 +926,9 @@ class CameraPickerState extends State 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); } @@ -1061,9 +1061,9 @@ class CameraPickerState extends State 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); }