Skip to content

Commit

Permalink
🚑️ Fix the too early widget access in CameraPickerState (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored Aug 14, 2022
1 parent 0e5a391 commit 6e01656
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ that can be found in the LICENSE file. -->

# Changelog

## 3.5.0+1

### Fixes

- Fix the too early `widget` access in `CameraPickerState`. (#124)

## 3.5.0

### New features
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: wechat_camera_picker_demo
description: A new Flutter project.
version: 3.5.0+14
version: 3.5.0+15
publish_to: none

environment:
Expand Down
7 changes: 2 additions & 5 deletions lib/src/states/camera_picker_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ const Duration _kDuration = Duration(milliseconds: 300);

class CameraPickerState extends State<CameraPicker>
with WidgetsBindingObserver {
CameraPickerState({Locale? locale}) {
Constants.textDelegate = widget.pickerConfig.textDelegate ??
cameraPickerTextDelegateFromLocale(locale);
}

/// The [Duration] for record detection. (200ms)
/// 检测是否开始录制的时长 (200毫秒)
final Duration recordDetectDuration = const Duration(milliseconds: 200);
Expand Down Expand Up @@ -164,6 +159,8 @@ class CameraPickerState extends State<CameraPicker>
void initState() {
super.initState();
ambiguate(WidgetsBinding.instance)?.addObserver(this);
Constants.textDelegate = widget.pickerConfig.textDelegate ??
cameraPickerTextDelegateFromLocale(widget.locale);

// TODO(Alex): Currently hide status bar will cause the viewport shaking on Android.
/// Hide system status bar automatically when the platform is not Android.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/camera_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ class CameraPicker extends StatefulWidget {
@override
CameraPickerState createState() =>
// ignore: no_logic_in_create_state
createPickerState?.call() ?? CameraPickerState(locale: locale);
createPickerState?.call() ?? CameraPickerState();
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: wechat_camera_picker
description: A camera picker which is an extension to wechat_assets_picker, but can be run separately.
version: 3.5.0
version: 3.5.0+1
homepage: https://github.com/fluttercandies/flutter_wechat_camera_picker

environment:
Expand Down

0 comments on commit 6e01656

Please sign in to comment.