@@ -232,6 +232,9 @@ class CameraPickerState extends State<CameraPicker>
232
232
/// The locked capture orientation of the current camera instance.
233
233
DeviceOrientation ? lockedCaptureOrientation;
234
234
235
+ /// The calculated capture actions section height.
236
+ double ? lastCaptureActionsEffectiveHeight;
237
+
235
238
@override
236
239
void initState () {
237
240
super .initState ();
@@ -684,10 +687,10 @@ class CameraPickerState extends State<CameraPicker>
684
687
/// 处理双指缩放更新
685
688
Future <void > handleScaleUpdate (ScaleUpdateDetails details) async {
686
689
// When there are not exactly two fingers on screen don't scale
687
- if (pointers != 2 ) {
690
+ if (innerController == null || pointers != 2 ) {
688
691
return ;
689
692
}
690
- zoom (details.scale);
693
+ zoom (details.scale * 2 - 1 );
691
694
}
692
695
693
696
void restartExposurePointDisplayTimer () {
@@ -926,17 +929,16 @@ class CameraPickerState extends State<CameraPicker>
926
929
Navigator .of (context).pop (entity);
927
930
return ;
928
931
}
929
- await Future .wait (< Future <void >> [
932
+ wrapControllerMethod <void >(
933
+ 'setFocusMode' ,
934
+ () => controller.setFocusMode (FocusMode .auto),
935
+ );
936
+ if (previousExposureMode != ExposureMode .locked) {
930
937
wrapControllerMethod <void >(
931
- 'setFocusMode' ,
932
- () => controller.setFocusMode (FocusMode .auto),
933
- ),
934
- if (previousExposureMode != ExposureMode .locked)
935
- wrapControllerMethod <void >(
936
- 'setExposureMode' ,
937
- () => controller.setExposureMode (previousExposureMode),
938
- ),
939
- ]);
938
+ 'setExposureMode' ,
939
+ () => controller.setExposureMode (previousExposureMode),
940
+ );
941
+ }
940
942
await controller.resumePreview ();
941
943
} catch (e, s) {
942
944
handleErrorWithHandler (e, s, pickerConfig.onError);
@@ -1283,8 +1285,9 @@ class CameraPickerState extends State<CameraPicker>
1283
1285
return AnimatedOpacity (
1284
1286
duration: recordDetectDuration,
1285
1287
opacity: controller? .value.isRecordingVideo ?? false ? 0 : 1 ,
1286
- child: Padding (
1287
- padding: const EdgeInsets .all (20 ),
1288
+ child: Container (
1289
+ height: 48.0 ,
1290
+ alignment: Alignment .center,
1288
1291
child: Text (
1289
1292
tips,
1290
1293
style: const TextStyle (fontSize: 15 ),
@@ -1304,13 +1307,15 @@ class CameraPickerState extends State<CameraPicker>
1304
1307
required BoxConstraints constraints,
1305
1308
CameraController ? controller,
1306
1309
}) {
1307
- const fallbackSize = 184 .0 ;
1310
+ const fallbackSize = 150 .0 ;
1308
1311
final previewSize = controller? .value.previewSize;
1309
1312
final orientation = controller? .value.deviceOrientation ??
1310
1313
MediaQuery .orientationOf (context);
1311
1314
final isPortrait = orientation.toString ().contains ('portrait' );
1312
1315
double effectiveSize;
1313
- if (previewSize != null ) {
1316
+ if (controller == null || pickerConfig.enableScaledPreview) {
1317
+ effectiveSize = lastCaptureActionsEffectiveHeight ?? fallbackSize;
1318
+ } else if (previewSize != null ) {
1314
1319
Size constraintSize = Size (constraints.maxWidth, constraints.maxHeight);
1315
1320
if (isPortrait && constraintSize.aspectRatio > 1 ||
1316
1321
! isPortrait && constraintSize.aspectRatio < 1 ) {
@@ -1323,9 +1328,11 @@ class CameraPickerState extends State<CameraPicker>
1323
1328
effectiveSize = constraintSize.width -
1324
1329
constraintSize.height * previewSize.aspectRatio;
1325
1330
}
1331
+ } else if (lastCaptureActionsEffectiveHeight != null ) {
1332
+ effectiveSize = lastCaptureActionsEffectiveHeight! ;
1326
1333
} else {
1327
1334
// Fallback to a reasonable height.
1328
- effectiveSize = 184.0 ;
1335
+ effectiveSize = fallbackSize ;
1329
1336
}
1330
1337
if (effectiveSize <= 0 ) {
1331
1338
realDebugPrint (
@@ -1334,11 +1341,14 @@ class CameraPickerState extends State<CameraPicker>
1334
1341
'orientation: $orientation ' ,
1335
1342
);
1336
1343
effectiveSize = fallbackSize;
1344
+ } else if (effectiveSize < fallbackSize) {
1345
+ effectiveSize = fallbackSize;
1337
1346
}
1338
-
1339
- return SizedBox (
1347
+ lastCaptureActionsEffectiveHeight = effectiveSize;
1348
+ return Container (
1340
1349
width: isPortrait ? null : effectiveSize,
1341
1350
height: isPortrait ? effectiveSize : null ,
1351
+ padding: EdgeInsets .only (bottom: MediaQuery .paddingOf (context).bottom),
1342
1352
child: Flex (
1343
1353
direction: isPortrait ? Axis .horizontal : Axis .vertical,
1344
1354
verticalDirection: orientation == DeviceOrientation .landscapeLeft
@@ -1670,8 +1680,8 @@ class CameraPickerState extends State<CameraPicker>
1670
1680
image: true ,
1671
1681
onTap: () {
1672
1682
// Focus on the center point when using semantics tap.
1673
- final Size size = MediaQuery .of (context).size ;
1674
- final TapUpDetails details = TapUpDetails (
1683
+ final size = MediaQuery .sizeOf (context);
1684
+ final details = TapUpDetails (
1675
1685
kind: PointerDeviceKind .touch,
1676
1686
globalPosition: Offset (size.width / 2 , size.height / 2 ),
1677
1687
);
@@ -1752,22 +1762,6 @@ class CameraPickerState extends State<CameraPicker>
1752
1762
preview = Stack (
1753
1763
children: < Widget > [
1754
1764
preview,
1755
- Positioned .fill (
1756
- child: ExcludeSemantics (
1757
- child: RotatedBox (
1758
- quarterTurns: cameraQuarterTurns,
1759
- child: Align (
1760
- alignment: {
1761
- DeviceOrientation .portraitUp: Alignment .bottomCenter,
1762
- DeviceOrientation .portraitDown: Alignment .topCenter,
1763
- DeviceOrientation .landscapeLeft: Alignment .centerRight,
1764
- DeviceOrientation .landscapeRight: Alignment .centerLeft,
1765
- }[cameraValue.deviceOrientation]! ,
1766
- child: buildCaptureTips (innerController),
1767
- ),
1768
- ),
1769
- ),
1770
- ),
1771
1765
if (pickerConfig.enableSetExposure)
1772
1766
buildExposureDetector (context, constraints),
1773
1767
buildFocusingPoint (
@@ -1827,9 +1821,10 @@ class CameraPickerState extends State<CameraPicker>
1827
1821
BoxConstraints constraints,
1828
1822
DeviceOrientation ? deviceOrientation,
1829
1823
) {
1830
- final orientation = deviceOrientation ?? MediaQuery .of (context).orientation ;
1824
+ final orientation = deviceOrientation ?? MediaQuery .orientationOf (context);
1831
1825
final isPortrait = orientation.toString ().contains ('portrait' );
1832
1826
return SafeArea (
1827
+ bottom: false ,
1833
1828
child: Flex (
1834
1829
direction: isPortrait ? Axis .vertical : Axis .horizontal,
1835
1830
textDirection: orientation == DeviceOrientation .landscapeRight
@@ -1844,8 +1839,7 @@ class CameraPickerState extends State<CameraPicker>
1844
1839
child: buildSettingActions (context),
1845
1840
),
1846
1841
const Spacer (),
1847
- if (enableScaledPreview)
1848
- ExcludeSemantics (child: buildCaptureTips (innerController)),
1842
+ ExcludeSemantics (child: buildCaptureTips (innerController)),
1849
1843
Semantics (
1850
1844
sortKey: const OrdinalSortKey (2 ),
1851
1845
hidden: innerController == null ,
@@ -1907,8 +1901,8 @@ class CameraPickerState extends State<CameraPicker>
1907
1901
image: true ,
1908
1902
onTap: () {
1909
1903
// Focus on the center point when using semantics tap.
1910
- final Size size = MediaQuery .of (context).size ;
1911
- final TapUpDetails details = TapUpDetails (
1904
+ final size = MediaQuery .sizeOf (context);
1905
+ final details = TapUpDetails (
1912
1906
kind: PointerDeviceKind .touch,
1913
1907
globalPosition: Offset (size.width / 2 , size.height / 2 ),
1914
1908
);
0 commit comments