@@ -1245,7 +1245,10 @@ class CameraPickerState extends State<CameraPicker>
12451245 return const SizedBox .shrink ();
12461246 }
12471247 Widget backButton = buildBackButton (context);
1248- Widget flashModeSwitch = buildFlashModeSwitch (context, v);
1248+ Widget flashModeSwitch = buildFlashModeSwitch (
1249+ context: context,
1250+ cameraValue: v,
1251+ );
12491252 if (isCameraRotated && ! enableScaledPreview) {
12501253 backButton = RotatedBox (
12511254 quarterTurns: cameraQuarterTurns,
@@ -1296,9 +1299,12 @@ class CameraPickerState extends State<CameraPicker>
12961299
12971300 /// The button to switch flash modes.
12981301 /// 切换闪光灯模式的按钮
1299- Widget buildFlashModeSwitch (BuildContext context, CameraValue value) {
1302+ Widget buildFlashModeSwitch ({
1303+ required BuildContext context,
1304+ required CameraValue cameraValue,
1305+ }) {
13001306 final IconData icon;
1301- switch (value .flashMode) {
1307+ switch (cameraValue .flashMode) {
13021308 case FlashMode .off:
13031309 icon = Icons .flash_off;
13041310 break ;
@@ -1313,15 +1319,18 @@ class CameraPickerState extends State<CameraPicker>
13131319 break ;
13141320 }
13151321 return IconButton (
1316- onPressed: () => switchFlashesMode (value ),
1317- tooltip: textDelegate.sFlashModeLabel (value .flashMode),
1322+ onPressed: () => switchFlashesMode (cameraValue ),
1323+ tooltip: textDelegate.sFlashModeLabel (cameraValue .flashMode),
13181324 icon: Icon (icon, size: 24 ),
13191325 );
13201326 }
13211327
13221328 /// Text widget for shooting tips.
13231329 /// 拍摄的提示文字
1324- Widget buildCaptureTips (CameraController ? controller) {
1330+ Widget buildCaptureTips ({
1331+ required BuildContext context,
1332+ CameraController ? controller,
1333+ }) {
13251334 return AnimatedOpacity (
13261335 duration: recordDetectDuration,
13271336 opacity: controller? .value.isRecordingVideo ?? false ? 0 : 1 ,
@@ -1398,7 +1407,10 @@ class CameraPickerState extends State<CameraPicker>
13981407 const Spacer (),
13991408 Expanded (
14001409 child: Center (
1401- child: buildCaptureButton (context, constraints),
1410+ child: buildCaptureButton (
1411+ context: context,
1412+ constraints: constraints,
1413+ ),
14021414 ),
14031415 ),
14041416 if (controller != null &&
@@ -1429,7 +1441,10 @@ class CameraPickerState extends State<CameraPicker>
14291441
14301442 /// The shooting button.
14311443 /// 拍照按钮
1432- Widget buildCaptureButton (BuildContext context, BoxConstraints constraints) {
1444+ Widget buildCaptureButton ({
1445+ required BuildContext context,
1446+ required BoxConstraints constraints,
1447+ }) {
14331448 final showProgressIndicator =
14341449 isCaptureButtonTapDown || MediaQuery .accessibleNavigationOf (context);
14351450
@@ -1500,7 +1515,8 @@ class CameraPickerState extends State<CameraPicker>
15001515 showProgressIndicator && isShootingButtonAnimate,
15011516 duration: pickerConfig.maximumRecordingDuration! ,
15021517 size: size,
1503- ringsColor: theme.indicatorColor,
1518+ // ignore: deprecated_member_use
1519+ ringsColor: Theme .of (context).indicatorColor,
15041520 ringsWidth: 3 ,
15051521 ),
15061522 ),
@@ -1514,13 +1530,14 @@ class CameraPickerState extends State<CameraPicker>
15141530 }
15151531
15161532 Widget buildExposureSlider ({
1533+ required BuildContext context,
15171534 required ExposureMode mode,
15181535 required double size,
15191536 required double height,
15201537 required double gap,
15211538 }) {
15221539 final bool isLocked = mode == ExposureMode .locked;
1523- final Color ? color = isLocked ? _lockedColor : theme .iconTheme.color;
1540+ final color = isLocked ? _lockedColor : Theme . of (context) .iconTheme.color;
15241541 final Widget lineWidget = ValueListenableBuilder <bool >(
15251542 valueListenable: isFocusPointDisplays,
15261543 builder: (_, bool value, Widget ? child) => AnimatedOpacity (
@@ -1580,6 +1597,7 @@ class CameraPickerState extends State<CameraPicker>
15801597 /// The area widget for the last exposure point that user manually set.
15811598 /// 用户手动设置的曝光点的区域显示
15821599 Widget buildFocusingPoint ({
1600+ required BuildContext context,
15831601 required CameraValue cameraValue,
15841602 required BoxConstraints constraints,
15851603 int quarterTurns = 0 ,
@@ -1612,6 +1630,7 @@ class CameraPickerState extends State<CameraPicker>
16121630 const SizedBox (height: verticalGap),
16131631 Expanded (
16141632 child: buildExposureSlider (
1633+ context: context,
16151634 mode: exposureMode,
16161635 size: size,
16171636 height: height,
@@ -1698,7 +1717,7 @@ class CameraPickerState extends State<CameraPicker>
16981717 size: pointWidth,
16991718 color: cameraValue.exposureMode == ExposureMode .locked
17001719 ? _lockedColor
1701- : theme. iconTheme.color! ,
1720+ : Theme . of (context). iconTheme.color,
17021721 ),
17031722 ),
17041723 ),
@@ -1718,10 +1737,10 @@ class CameraPickerState extends State<CameraPicker>
17181737
17191738 /// The [GestureDetector] widget for setting exposure point manually.
17201739 /// 用于手动设置曝光点的 [GestureDetector]
1721- Widget buildExposureDetector (
1722- BuildContext context,
1723- BoxConstraints constraints,
1724- ) {
1740+ Widget buildExposureDetector ({
1741+ required BuildContext context,
1742+ required BoxConstraints constraints,
1743+ } ) {
17251744 return Semantics (
17261745 label: textDelegate.sCameraPreviewLabel (
17271746 innerController? .description.lensDirection,
@@ -1812,8 +1831,9 @@ class CameraPickerState extends State<CameraPicker>
18121831 children: < Widget > [
18131832 preview,
18141833 if (pickerConfig.enableSetExposure)
1815- buildExposureDetector (context, constraints),
1834+ buildExposureDetector (context: context, constraints : constraints),
18161835 buildFocusingPoint (
1836+ context: context,
18171837 cameraValue: cameraValue,
18181838 constraints: constraints,
18191839 quarterTurns: cameraQuarterTurns,
@@ -1865,11 +1885,11 @@ class CameraPickerState extends State<CameraPicker>
18651885 );
18661886 }
18671887
1868- Widget buildForegroundBody (
1869- BuildContext context,
1870- BoxConstraints constraints,
1888+ Widget buildForegroundBody ({
1889+ required BuildContext context,
1890+ required BoxConstraints constraints,
18711891 DeviceOrientation ? deviceOrientation,
1872- ) {
1892+ } ) {
18731893 final orientation = deviceOrientation ?? MediaQuery .orientationOf (context);
18741894 final isPortrait = orientation.toString ().contains ('portrait' );
18751895 return SafeArea (
@@ -1888,7 +1908,12 @@ class CameraPickerState extends State<CameraPicker>
18881908 child: buildSettingActions (context),
18891909 ),
18901910 const Spacer (),
1891- ExcludeSemantics (child: buildCaptureTips (innerController)),
1911+ ExcludeSemantics (
1912+ child: buildCaptureTips (
1913+ context: context,
1914+ controller: innerController,
1915+ ),
1916+ ),
18921917 Semantics (
18931918 sortKey: const OrdinalSortKey (2 ),
18941919 hidden: innerController == null ,
@@ -1974,9 +1999,13 @@ class CameraPickerState extends State<CameraPicker>
19741999 previewWidget,
19752000 if (enableScaledPreview) ...< Widget > [
19762001 if (pickerConfig.enableSetExposure)
1977- buildExposureDetector (context, constraints),
2002+ buildExposureDetector (
2003+ context: context,
2004+ constraints: constraints,
2005+ ),
19782006 buildInitializeWrapper (
19792007 builder: (CameraValue v, _) => buildFocusingPoint (
2008+ context: context,
19802009 cameraValue: v,
19812010 constraints: constraints,
19822011 ),
@@ -1988,13 +2017,17 @@ class CameraPickerState extends State<CameraPicker>
19882017 ),
19892018 ],
19902019 if (innerController == null )
1991- buildForegroundBody (context, constraints, null )
2020+ buildForegroundBody (
2021+ context: context,
2022+ constraints: constraints,
2023+ deviceOrientation: null ,
2024+ )
19922025 else
19932026 buildInitializeWrapper (
19942027 builder: (CameraValue v, _) => buildForegroundBody (
1995- context,
1996- constraints,
1997- v.deviceOrientation,
2028+ context: context ,
2029+ constraints: constraints ,
2030+ deviceOrientation : v.deviceOrientation,
19982031 ),
19992032 ),
20002033 ],
@@ -2005,21 +2038,6 @@ class CameraPickerState extends State<CameraPicker>
20052038
20062039 @override
20072040 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- }
20232041 return AnnotatedRegion <SystemUiOverlayStyle >(
20242042 value: const SystemUiOverlayStyle (
20252043 systemNavigationBarIconBrightness: Brightness .light,
@@ -2028,9 +2046,25 @@ class CameraPickerState extends State<CameraPicker>
20282046 ),
20292047 child: Theme (
20302048 data: theme,
2031- child: Material (
2032- color: Colors .black,
2033- child: body,
2049+ child: Builder (
2050+ builder: (context) {
2051+ Widget body = buildBody (context);
2052+ if (isCameraRotated && enableScaledPreview) {
2053+ final MediaQueryData mq = MediaQuery .of (context);
2054+ body = RotatedBox (
2055+ quarterTurns: pickerConfig.cameraQuarterTurns,
2056+ child: MediaQuery (
2057+ data: mq.copyWith (
2058+ size: pickerConfig.cameraQuarterTurns.isOdd
2059+ ? mq.size.flipped
2060+ : mq.size,
2061+ ),
2062+ child: body,
2063+ ),
2064+ );
2065+ }
2066+ return Material (color: Colors .black, child: body);
2067+ },
20342068 ),
20352069 ),
20362070 );
0 commit comments