From 8fcbb0e701cfe4f5427f795d28dd812bd0cc89c1 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Tue, 26 Mar 2024 18:00:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20Allows=20`wrapControllerMeth?= =?UTF-8?q?od`=20to=20return=20nullable=20result?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/states/camera_picker_state.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/states/camera_picker_state.dart b/lib/src/states/camera_picker_state.dart index 906d683..45c8d3f 100644 --- a/lib/src/states/camera_picker_state.dart +++ b/lib/src/states/camera_picker_state.dart @@ -304,7 +304,7 @@ class CameraPickerState extends State /// /// 对于 [CameraController] 的方法增加是否无效的控制。 /// 如果 [T] 是非 void 且方法无效,返回 [fallback]。 - Future wrapControllerMethod( + Future wrapControllerMethod( String key, Future Function() method, { CameraDescription? description, @@ -313,7 +313,7 @@ class CameraPickerState extends State }) async { description ??= currentCamera; if (invalidControllerMethods[description]!.contains(key)) { - return fallback!; + return fallback; } try { return await method(); @@ -431,37 +431,37 @@ class CameraPickerState extends State () => newController.getExposureOffsetStepSize(), description: description, fallback: exposureStep, - ).then((value) => exposureStep = value), + ).then((value) => exposureStep = value!), wrapControllerMethod( 'getMaxExposureOffset', () => newController.getMaxExposureOffset(), description: description, fallback: maxAvailableExposureOffset, - ).then((value) => maxAvailableExposureOffset = value), + ).then((value) => maxAvailableExposureOffset = value!), wrapControllerMethod( 'getMinExposureOffset', () => newController.getMinExposureOffset(), description: description, fallback: minAvailableExposureOffset, - ).then((value) => minAvailableExposureOffset = value), + ).then((value) => minAvailableExposureOffset = value!), wrapControllerMethod( 'getMaxZoomLevel', () => newController.getMaxZoomLevel(), description: description, fallback: maxAvailableZoom, - ).then((value) => maxAvailableZoom = value), + ).then((value) => maxAvailableZoom = value!), wrapControllerMethod( 'getMinZoomLevel', () => newController.getMinZoomLevel(), description: description, fallback: minAvailableZoom, - ).then((value) => minAvailableZoom = value), + ).then((value) => minAvailableZoom = value!), wrapControllerMethod( 'getMinZoomLevel', () => newController.getMinZoomLevel(), description: description, fallback: minAvailableZoom, - ).then((value) => minAvailableZoom = value), + ).then((value) => minAvailableZoom = value!), if (pickerConfig.lockCaptureOrientation != null) wrapControllerMethod( 'lockCaptureOrientation', From b55a1e0eed8c35ac5bc42a56dfcff333e9b3504a Mon Sep 17 00:00:00 2001 From: Alex Li Date: Tue, 26 Mar 2024 18:00:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=9A=B8=20Provide=20a=20back=20button?= =?UTF-8?q?=20when=20no=20controller=20has=20been=20initialized?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/states/camera_picker_state.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/states/camera_picker_state.dart b/lib/src/states/camera_picker_state.dart index 45c8d3f..8243325 100644 --- a/lib/src/states/camera_picker_state.dart +++ b/lib/src/states/camera_picker_state.dart @@ -1172,6 +1172,13 @@ class CameraPickerState extends State /// This displayed at the top of the screen. /// 该区域显示在屏幕上方。 Widget buildSettingActions(BuildContext context) { + if (innerController == null) { + return Container( + alignment: AlignmentDirectional.topStart, + padding: const EdgeInsets.symmetric(horizontal: 12), + child: buildBackButton(context), + ); + } return buildInitializeWrapper( builder: (CameraValue v, __) { if (v.isRecordingVideo) { @@ -1787,7 +1794,6 @@ class CameraPickerState extends State children: [ Semantics( sortKey: const OrdinalSortKey(0), - hidden: innerController == null, child: buildSettingActions(context), ), const Spacer(), From 9b8c4699424d1004721bdb31c15900df95a6f613 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Tue, 26 Mar 2024 18:01:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=94=96=204.2.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 ++++++++++ example/pubspec.yaml | 2 +- pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ab610..46e456e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ that can be found in the LICENSE file. --> See the [Migration Guide](guides/migration_guide.md) for breaking changes between versions. +## 4.2.2 + +### Fixes + +- Allows `wrapControllerMethod` to return nullable result + +### Improvements + +- Provide the back button when no controller has been initialized. + ## 4.2.1 ### Fixes diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b1f9145..126bc6b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: wechat_camera_picker_demo description: A new Flutter project. -version: 4.2.1+33 +version: 4.2.2+34 publish_to: none environment: diff --git a/pubspec.yaml b/pubspec.yaml index 8ad66d4..9200049 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: wechat_camera_picker -version: 4.2.1 +version: 4.2.2 description: | A camera picker for Flutter projects based on WeChat's UI, which is also a separate runnable extension to the