Skip to content

Commit 457c6b4

Browse files
authored
🚸 Prevent unnecessary zoom updates (#107)
1 parent 85820b0 commit 457c6b4

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ that can be found in the LICENSE file. -->
44

55
# Changelog
66

7+
## 3.3.1
8+
9+
### Improvements
10+
11+
- Prevent unnecessary zoom updates. (#107)
12+
713
## 3.3.0
814

915
### Breaking Changes

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wechat_camera_picker_demo
22
description: A new Flutter project.
3-
version: 3.3.0+11
3+
version: 3.3.1+12
44
publish_to: none
55

66
environment:

lib/src/widgets/camera_picker.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,12 @@ class CameraPickerState extends State<CameraPicker>
492492
}
493493

494494
Future<void> zoom(double scale) async {
495+
if (_maxAvailableZoom == _minAvailableZoom) {
496+
return;
497+
}
498+
if (_recordDetectTimer?.isActive ?? false) {
499+
return;
500+
}
495501
final double zoom = (_baseZoom * scale).clamp(
496502
_minAvailableZoom,
497503
_maxAvailableZoom,
@@ -500,8 +506,11 @@ class CameraPickerState extends State<CameraPicker>
500506
return;
501507
}
502508
_currentZoom = zoom;
503-
504-
await controller.setZoomLevel(_currentZoom);
509+
try {
510+
await controller.setZoomLevel(_currentZoom);
511+
} catch (e, s) {
512+
handleErrorWithHandler(e, config.onError, s: s);
513+
}
505514
}
506515

507516
/// Handle when the scale gesture start.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wechat_camera_picker
22
description: A camera picker which is an extension to wechat_assets_picker, but can be run separately.
3-
version: 3.3.0
3+
version: 3.3.1
44
homepage: https://github.com/fluttercandies/flutter_wechat_camera_picker
55

66
environment:

0 commit comments

Comments
 (0)