@@ -7,7 +7,6 @@ import 'dart:async';
7
7
import 'dart:io' ;
8
8
import 'dart:math' as math;
9
9
10
- import 'package:bindings_compatible/bindings_compatible.dart' ;
11
10
import 'package:camera/camera.dart' ;
12
11
import 'package:camera_platform_interface/camera_platform_interface.dart' ;
13
12
import 'package:flutter/gestures.dart' ;
@@ -49,7 +48,9 @@ class CameraPickerState extends State<CameraPicker>
49
48
/// 在开始录像前,最后一次在拍照按钮按下的位置
50
49
Offset ? lastShootingButtonPressedPosition;
51
50
52
- final ValueNotifier <bool > isExposureModeDisplays = ValueNotifier <bool >(false );
51
+ /// Whether the focus point is displaying.
52
+ /// 是否正在展示当前的聚焦点
53
+ final ValueNotifier <bool > isFocusPointDisplays = ValueNotifier <bool >(false );
53
54
54
55
/// The controller for the current camera.
55
56
/// 当前相机实例的控制器
@@ -58,7 +59,7 @@ class CameraPickerState extends State<CameraPicker>
58
59
59
60
/// Available cameras.
60
61
/// 可用的相机实例
61
- late List <CameraDescription > cameras;
62
+ late final List <CameraDescription > cameras;
62
63
63
64
/// Current exposure offset.
64
65
/// 当前曝光值
@@ -162,7 +163,7 @@ class CameraPickerState extends State<CameraPicker>
162
163
@override
163
164
void initState () {
164
165
super .initState ();
165
- useWidgetsBinding () .addObserver (this );
166
+ ambiguate ( WidgetsBinding .instance) ? .addObserver (this );
166
167
167
168
// TODO(Alex): Currently hide status bar will cause the viewport shaking on Android.
168
169
/// Hide system status bar automatically when the platform is not Android.
@@ -179,11 +180,11 @@ class CameraPickerState extends State<CameraPicker>
179
180
if (! Platform .isAndroid) {
180
181
SystemChrome .setEnabledSystemUIOverlays (SystemUiOverlay .values);
181
182
}
182
- useWidgetsBinding () .removeObserver (this );
183
+ ambiguate ( WidgetsBinding .instance) ? .removeObserver (this );
183
184
innerController? .dispose ();
184
185
currentExposureOffset.dispose ();
185
186
lastExposurePoint.dispose ();
186
- isExposureModeDisplays .dispose ();
187
+ isFocusPointDisplays .dispose ();
187
188
exposurePointDisplayTimer? .cancel ();
188
189
exposureModeDisplayTimer? .cancel ();
189
190
recordDetectTimer? .cancel ();
@@ -255,7 +256,7 @@ class CameraPickerState extends State<CameraPicker>
255
256
});
256
257
// **IMPORTANT**: Push methods into a post frame callback, which ensures the
257
258
// controller has already unbind from widgets.
258
- useWidgetsBinding () .addPostFrameCallback ((_) async {
259
+ ambiguate ( WidgetsBinding .instance) ? .addPostFrameCallback ((_) async {
259
260
// When the [cameraDescription] is null, which means this is the first
260
261
// time initializing cameras, so available cameras should be fetched.
261
262
if (cameraDescription == null ) {
@@ -264,7 +265,7 @@ class CameraPickerState extends State<CameraPicker>
264
265
265
266
// After cameras fetched, judge again with the list is empty or not to
266
267
// ensure there is at least an available camera for use.
267
- if (cameraDescription == null && ( cameras.isEmpty) ) {
268
+ if (cameraDescription == null && cameras.isEmpty) {
268
269
handleErrorWithHandler (
269
270
CameraException (
270
271
'No CameraDescription found.' ,
@@ -440,7 +441,7 @@ class CameraPickerState extends State<CameraPicker>
440
441
void restartDisplayModeDisplayTimer () {
441
442
exposureModeDisplayTimer? .cancel ();
442
443
exposureModeDisplayTimer = Timer (const Duration (seconds: 2 ), () {
443
- isExposureModeDisplays .value = false ;
444
+ isFocusPointDisplays .value = false ;
444
445
});
445
446
}
446
447
@@ -474,7 +475,7 @@ class CameraPickerState extends State<CameraPicker>
474
475
Offset position,
475
476
BoxConstraints constraints,
476
477
) async {
477
- isExposureModeDisplays .value = false ;
478
+ isFocusPointDisplays .value = false ;
478
479
// Ignore point update when the new point is less than 8% and higher than
479
480
// 92% of the screen's height.
480
481
if (position.dy < constraints.maxHeight / 12 ||
@@ -535,8 +536,8 @@ class CameraPickerState extends State<CameraPicker>
535
536
} catch (e, s) {
536
537
handleErrorWithHandler (e, pickerConfig.onError, s: s);
537
538
}
538
- if (! isExposureModeDisplays .value) {
539
- isExposureModeDisplays .value = true ;
539
+ if (! isFocusPointDisplays .value) {
540
+ isFocusPointDisplays .value = true ;
540
541
}
541
542
restartDisplayModeDisplayTimer ();
542
543
restartExposurePointDisplayTimer ();
@@ -1008,7 +1009,7 @@ class CameraPickerState extends State<CameraPicker>
1008
1009
final bool isLocked = mode == ExposureMode .locked;
1009
1010
final Color ? color = isLocked ? _lockedColor : theme.iconTheme.color;
1010
1011
final Widget lineWidget = ValueListenableBuilder <bool >(
1011
- valueListenable: isExposureModeDisplays ,
1012
+ valueListenable: isFocusPointDisplays ,
1012
1013
builder: (_, bool value, Widget ? child) => AnimatedOpacity (
1013
1014
duration: _kDuration,
1014
1015
opacity: value ? 1 : 0 ,
@@ -1077,7 +1078,7 @@ class CameraPickerState extends State<CameraPicker>
1077
1078
return Column (
1078
1079
children: < Widget > [
1079
1080
ValueListenableBuilder <bool >(
1080
- valueListenable: isExposureModeDisplays ,
1081
+ valueListenable: isFocusPointDisplays ,
1081
1082
builder: (_, bool value, Widget ? child) => AnimatedOpacity (
1082
1083
duration: _kDuration,
1083
1084
opacity: value ? 1 : 0 ,
0 commit comments