@@ -1245,7 +1245,10 @@ class CameraPickerState extends State<CameraPicker>
1245
1245
return const SizedBox .shrink ();
1246
1246
}
1247
1247
Widget backButton = buildBackButton (context);
1248
- Widget flashModeSwitch = buildFlashModeSwitch (context, v);
1248
+ Widget flashModeSwitch = buildFlashModeSwitch (
1249
+ context: context,
1250
+ cameraValue: v,
1251
+ );
1249
1252
if (isCameraRotated && ! enableScaledPreview) {
1250
1253
backButton = RotatedBox (
1251
1254
quarterTurns: cameraQuarterTurns,
@@ -1296,9 +1299,12 @@ class CameraPickerState extends State<CameraPicker>
1296
1299
1297
1300
/// The button to switch flash modes.
1298
1301
/// 切换闪光灯模式的按钮
1299
- Widget buildFlashModeSwitch (BuildContext context, CameraValue value) {
1302
+ Widget buildFlashModeSwitch ({
1303
+ required BuildContext context,
1304
+ required CameraValue cameraValue,
1305
+ }) {
1300
1306
final IconData icon;
1301
- switch (value .flashMode) {
1307
+ switch (cameraValue .flashMode) {
1302
1308
case FlashMode .off:
1303
1309
icon = Icons .flash_off;
1304
1310
break ;
@@ -1313,15 +1319,18 @@ class CameraPickerState extends State<CameraPicker>
1313
1319
break ;
1314
1320
}
1315
1321
return IconButton (
1316
- onPressed: () => switchFlashesMode (value ),
1317
- tooltip: textDelegate.sFlashModeLabel (value .flashMode),
1322
+ onPressed: () => switchFlashesMode (cameraValue ),
1323
+ tooltip: textDelegate.sFlashModeLabel (cameraValue .flashMode),
1318
1324
icon: Icon (icon, size: 24 ),
1319
1325
);
1320
1326
}
1321
1327
1322
1328
/// Text widget for shooting tips.
1323
1329
/// 拍摄的提示文字
1324
- Widget buildCaptureTips (CameraController ? controller) {
1330
+ Widget buildCaptureTips ({
1331
+ required BuildContext context,
1332
+ CameraController ? controller,
1333
+ }) {
1325
1334
return AnimatedOpacity (
1326
1335
duration: recordDetectDuration,
1327
1336
opacity: controller? .value.isRecordingVideo ?? false ? 0 : 1 ,
@@ -1398,7 +1407,10 @@ class CameraPickerState extends State<CameraPicker>
1398
1407
const Spacer (),
1399
1408
Expanded (
1400
1409
child: Center (
1401
- child: buildCaptureButton (context, constraints),
1410
+ child: buildCaptureButton (
1411
+ context: context,
1412
+ constraints: constraints,
1413
+ ),
1402
1414
),
1403
1415
),
1404
1416
if (controller != null &&
@@ -1429,7 +1441,10 @@ class CameraPickerState extends State<CameraPicker>
1429
1441
1430
1442
/// The shooting button.
1431
1443
/// 拍照按钮
1432
- Widget buildCaptureButton (BuildContext context, BoxConstraints constraints) {
1444
+ Widget buildCaptureButton ({
1445
+ required BuildContext context,
1446
+ required BoxConstraints constraints,
1447
+ }) {
1433
1448
final showProgressIndicator =
1434
1449
isCaptureButtonTapDown || MediaQuery .accessibleNavigationOf (context);
1435
1450
@@ -1514,6 +1529,7 @@ class CameraPickerState extends State<CameraPicker>
1514
1529
}
1515
1530
1516
1531
Widget buildExposureSlider ({
1532
+ required BuildContext context,
1517
1533
required ExposureMode mode,
1518
1534
required double size,
1519
1535
required double height,
@@ -1580,6 +1596,7 @@ class CameraPickerState extends State<CameraPicker>
1580
1596
/// The area widget for the last exposure point that user manually set.
1581
1597
/// 用户手动设置的曝光点的区域显示
1582
1598
Widget buildFocusingPoint ({
1599
+ required BuildContext context,
1583
1600
required CameraValue cameraValue,
1584
1601
required BoxConstraints constraints,
1585
1602
int quarterTurns = 0 ,
@@ -1612,6 +1629,7 @@ class CameraPickerState extends State<CameraPicker>
1612
1629
const SizedBox (height: verticalGap),
1613
1630
Expanded (
1614
1631
child: buildExposureSlider (
1632
+ context: context,
1615
1633
mode: exposureMode,
1616
1634
size: size,
1617
1635
height: height,
@@ -1718,10 +1736,10 @@ class CameraPickerState extends State<CameraPicker>
1718
1736
1719
1737
/// The [GestureDetector] widget for setting exposure point manually.
1720
1738
/// 用于手动设置曝光点的 [GestureDetector]
1721
- Widget buildExposureDetector (
1722
- BuildContext context,
1723
- BoxConstraints constraints,
1724
- ) {
1739
+ Widget buildExposureDetector ({
1740
+ required BuildContext context,
1741
+ required BoxConstraints constraints,
1742
+ } ) {
1725
1743
return Semantics (
1726
1744
label: textDelegate.sCameraPreviewLabel (
1727
1745
innerController? .description.lensDirection,
@@ -1812,8 +1830,9 @@ class CameraPickerState extends State<CameraPicker>
1812
1830
children: < Widget > [
1813
1831
preview,
1814
1832
if (pickerConfig.enableSetExposure)
1815
- buildExposureDetector (context, constraints),
1833
+ buildExposureDetector (context: context, constraints : constraints),
1816
1834
buildFocusingPoint (
1835
+ context: context,
1817
1836
cameraValue: cameraValue,
1818
1837
constraints: constraints,
1819
1838
quarterTurns: cameraQuarterTurns,
@@ -1865,11 +1884,11 @@ class CameraPickerState extends State<CameraPicker>
1865
1884
);
1866
1885
}
1867
1886
1868
- Widget buildForegroundBody (
1869
- BuildContext context,
1870
- BoxConstraints constraints,
1887
+ Widget buildForegroundBody ({
1888
+ required BuildContext context,
1889
+ required BoxConstraints constraints,
1871
1890
DeviceOrientation ? deviceOrientation,
1872
- ) {
1891
+ } ) {
1873
1892
final orientation = deviceOrientation ?? MediaQuery .orientationOf (context);
1874
1893
final isPortrait = orientation.toString ().contains ('portrait' );
1875
1894
return SafeArea (
@@ -1888,7 +1907,12 @@ class CameraPickerState extends State<CameraPicker>
1888
1907
child: buildSettingActions (context),
1889
1908
),
1890
1909
const Spacer (),
1891
- ExcludeSemantics (child: buildCaptureTips (innerController)),
1910
+ ExcludeSemantics (
1911
+ child: buildCaptureTips (
1912
+ context: context,
1913
+ controller: innerController,
1914
+ ),
1915
+ ),
1892
1916
Semantics (
1893
1917
sortKey: const OrdinalSortKey (2 ),
1894
1918
hidden: innerController == null ,
@@ -1974,9 +1998,13 @@ class CameraPickerState extends State<CameraPicker>
1974
1998
previewWidget,
1975
1999
if (enableScaledPreview) ...< Widget > [
1976
2000
if (pickerConfig.enableSetExposure)
1977
- buildExposureDetector (context, constraints),
2001
+ buildExposureDetector (
2002
+ context: context,
2003
+ constraints: constraints,
2004
+ ),
1978
2005
buildInitializeWrapper (
1979
2006
builder: (CameraValue v, _) => buildFocusingPoint (
2007
+ context: context,
1980
2008
cameraValue: v,
1981
2009
constraints: constraints,
1982
2010
),
@@ -1988,13 +2016,17 @@ class CameraPickerState extends State<CameraPicker>
1988
2016
),
1989
2017
],
1990
2018
if (innerController == null )
1991
- buildForegroundBody (context, constraints, null )
2019
+ buildForegroundBody (
2020
+ context: context,
2021
+ constraints: constraints,
2022
+ deviceOrientation: null ,
2023
+ )
1992
2024
else
1993
2025
buildInitializeWrapper (
1994
2026
builder: (CameraValue v, _) => buildForegroundBody (
1995
- context,
1996
- constraints,
1997
- v.deviceOrientation,
2027
+ context: context ,
2028
+ constraints: constraints ,
2029
+ deviceOrientation : v.deviceOrientation,
1998
2030
),
1999
2031
),
2000
2032
],
@@ -2005,21 +2037,6 @@ class CameraPickerState extends State<CameraPicker>
2005
2037
2006
2038
@override
2007
2039
Widget build (BuildContext context) {
2008
- Widget body = Builder (builder: buildBody);
2009
- if (isCameraRotated && enableScaledPreview) {
2010
- final MediaQueryData mq = MediaQuery .of (context);
2011
- body = RotatedBox (
2012
- quarterTurns: pickerConfig.cameraQuarterTurns,
2013
- child: MediaQuery (
2014
- data: mq.copyWith (
2015
- size: pickerConfig.cameraQuarterTurns.isOdd
2016
- ? mq.size.flipped
2017
- : mq.size,
2018
- ),
2019
- child: body,
2020
- ),
2021
- );
2022
- }
2023
2040
return AnnotatedRegion <SystemUiOverlayStyle >(
2024
2041
value: const SystemUiOverlayStyle (
2025
2042
systemNavigationBarIconBrightness: Brightness .light,
@@ -2028,9 +2045,25 @@ class CameraPickerState extends State<CameraPicker>
2028
2045
),
2029
2046
child: Theme (
2030
2047
data: theme,
2031
- child: Material (
2032
- color: Colors .black,
2033
- child: body,
2048
+ child: Builder (
2049
+ builder: (context) {
2050
+ Widget body = buildBody (context);
2051
+ if (isCameraRotated && enableScaledPreview) {
2052
+ final MediaQueryData mq = MediaQuery .of (context);
2053
+ body = RotatedBox (
2054
+ quarterTurns: pickerConfig.cameraQuarterTurns,
2055
+ child: MediaQuery (
2056
+ data: mq.copyWith (
2057
+ size: pickerConfig.cameraQuarterTurns.isOdd
2058
+ ? mq.size.flipped
2059
+ : mq.size,
2060
+ ),
2061
+ child: body,
2062
+ ),
2063
+ );
2064
+ }
2065
+ return Material (color: Colors .black, child: body);
2066
+ },
2034
2067
),
2035
2068
),
2036
2069
);
0 commit comments