Skip to content

Commit 6e01656

Browse files
authored
🚑️ Fix the too early widget access in CameraPickerState (#124)
1 parent 0e5a391 commit 6e01656

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
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.5.0+1
8+
9+
### Fixes
10+
11+
- Fix the too early `widget` access in `CameraPickerState`. (#124)
12+
713
## 3.5.0
814

915
### New features

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.5.0+14
3+
version: 3.5.0+15
44
publish_to: none
55

66
environment:

lib/src/states/camera_picker_state.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ const Duration _kDuration = Duration(milliseconds: 300);
3131

3232
class CameraPickerState extends State<CameraPicker>
3333
with WidgetsBindingObserver {
34-
CameraPickerState({Locale? locale}) {
35-
Constants.textDelegate = widget.pickerConfig.textDelegate ??
36-
cameraPickerTextDelegateFromLocale(locale);
37-
}
38-
3934
/// The [Duration] for record detection. (200ms)
4035
/// 检测是否开始录制的时长 (200毫秒)
4136
final Duration recordDetectDuration = const Duration(milliseconds: 200);
@@ -164,6 +159,8 @@ class CameraPickerState extends State<CameraPicker>
164159
void initState() {
165160
super.initState();
166161
ambiguate(WidgetsBinding.instance)?.addObserver(this);
162+
Constants.textDelegate = widget.pickerConfig.textDelegate ??
163+
cameraPickerTextDelegateFromLocale(widget.locale);
167164

168165
// TODO(Alex): Currently hide status bar will cause the viewport shaking on Android.
169166
/// Hide system status bar automatically when the platform is not Android.

lib/src/widgets/camera_picker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ class CameraPicker extends StatefulWidget {
111111
@override
112112
CameraPickerState createState() =>
113113
// ignore: no_logic_in_create_state
114-
createPickerState?.call() ?? CameraPickerState(locale: locale);
114+
createPickerState?.call() ?? CameraPickerState();
115115
}

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.5.0
3+
version: 3.5.0+1
44
homepage: https://github.com/fluttercandies/flutter_wechat_camera_picker
55

66
environment:

0 commit comments

Comments
 (0)