@@ -956,11 +956,13 @@ class CameraPickerState extends State<CameraPicker>
956
956
child: flashModeSwitch,
957
957
);
958
958
}
959
+ final isPortrait = v.deviceOrientation.toString ().contains ('portrait' );
959
960
return Padding (
960
961
padding: const EdgeInsets .symmetric (horizontal: 12 ),
961
- child: Row (
962
+ child: Flex (
963
+ direction: isPortrait ? Axis .horizontal : Axis .vertical,
962
964
children: < Widget > [
963
- if (innerController ? .value. isRecordingVideo != true ) backButton,
965
+ if (! v. isRecordingVideo) backButton,
964
966
const Spacer (),
965
967
flashModeSwitch,
966
968
],
@@ -1055,9 +1057,17 @@ class CameraPickerState extends State<CameraPicker>
1055
1057
required BoxConstraints constraints,
1056
1058
CameraController ? controller,
1057
1059
}) {
1060
+ final orientation = controller? .value.deviceOrientation ??
1061
+ MediaQuery .of (context).orientation;
1062
+ final isPortrait = orientation.toString ().contains ('portrait' );
1058
1063
return SizedBox (
1059
- height: 118 ,
1060
- child: Row (
1064
+ width: isPortrait ? null : 118 ,
1065
+ height: isPortrait ? 118 : null ,
1066
+ child: Flex (
1067
+ direction: isPortrait ? Axis .horizontal : Axis .vertical,
1068
+ verticalDirection: orientation == DeviceOrientation .landscapeLeft
1069
+ ? VerticalDirection .up
1070
+ : VerticalDirection .down,
1061
1071
children: < Widget > [
1062
1072
const Spacer (),
1063
1073
Expanded (
@@ -1268,7 +1278,8 @@ class CameraPickerState extends State<CameraPicker>
1268
1278
1269
1279
Widget buildFromPoint (Offset point) {
1270
1280
const double controllerWidth = 20 ;
1271
- final double pointWidth = constraints.maxWidth / 5 ;
1281
+ final double pointWidth =
1282
+ math.min (constraints.maxWidth, constraints.maxHeight) / 5 ;
1272
1283
final double lineHeight = pointWidth * 2.5 ;
1273
1284
final double exposureControlWidth =
1274
1285
pickerConfig.enableExposureControlOnPoint ? controllerWidth : 0 ;
@@ -1437,7 +1448,12 @@ class CameraPickerState extends State<CameraPicker>
1437
1448
child: RotatedBox (
1438
1449
quarterTurns: cameraQuarterTurns,
1439
1450
child: Align (
1440
- alignment: Alignment .bottomCenter,
1451
+ alignment: {
1452
+ DeviceOrientation .portraitUp: Alignment .bottomCenter,
1453
+ DeviceOrientation .portraitDown: Alignment .topCenter,
1454
+ DeviceOrientation .landscapeLeft: Alignment .centerRight,
1455
+ DeviceOrientation .landscapeRight: Alignment .centerLeft,
1456
+ }[cameraValue.deviceOrientation]! ,
1441
1457
child: buildCaptureTips (innerController),
1442
1458
),
1443
1459
),
@@ -1497,11 +1513,24 @@ class CameraPickerState extends State<CameraPicker>
1497
1513
);
1498
1514
}
1499
1515
1500
- Widget buildForegroundBody (BuildContext context, BoxConstraints constraints) {
1516
+ Widget buildForegroundBody (
1517
+ BuildContext context,
1518
+ BoxConstraints constraints,
1519
+ DeviceOrientation ? deviceOrientation,
1520
+ ) {
1521
+ final orientation = deviceOrientation ?? MediaQuery .of (context).orientation;
1522
+ final isPortrait = orientation.toString ().contains ('portrait' );
1501
1523
return SafeArea (
1502
1524
child: Padding (
1503
1525
padding: const EdgeInsets .only (bottom: 20 ),
1504
- child: Column (
1526
+ child: Flex (
1527
+ direction: isPortrait ? Axis .vertical : Axis .horizontal,
1528
+ textDirection: orientation == DeviceOrientation .landscapeRight
1529
+ ? TextDirection .rtl
1530
+ : TextDirection .ltr,
1531
+ verticalDirection: orientation == DeviceOrientation .portraitDown
1532
+ ? VerticalDirection .up
1533
+ : VerticalDirection .down,
1505
1534
children: < Widget > [
1506
1535
Semantics (
1507
1536
sortKey: const OrdinalSortKey (0 ),
@@ -1540,9 +1569,17 @@ class CameraPickerState extends State<CameraPicker>
1540
1569
);
1541
1570
}
1542
1571
return Align (
1543
- alignment: AlignmentDirectional .topCenter,
1572
+ alignment: {
1573
+ DeviceOrientation .portraitUp: Alignment .topCenter,
1574
+ DeviceOrientation .portraitDown: Alignment .bottomCenter,
1575
+ DeviceOrientation .landscapeLeft: Alignment .centerLeft,
1576
+ DeviceOrientation .landscapeRight: Alignment .centerRight,
1577
+ }[v.deviceOrientation]! ,
1544
1578
child: AspectRatio (
1545
- aspectRatio: 1 / v.aspectRatio,
1579
+ aspectRatio:
1580
+ v.deviceOrientation.toString ().contains ('portrait' )
1581
+ ? 1 / v.aspectRatio
1582
+ : v.aspectRatio,
1546
1583
child: LayoutBuilder (
1547
1584
builder: (BuildContext c, BoxConstraints constraints) {
1548
1585
return buildCameraPreview (
@@ -1602,7 +1639,16 @@ class CameraPickerState extends State<CameraPicker>
1602
1639
pickerConfig.foregroundBuilder !(context, innerController),
1603
1640
),
1604
1641
],
1605
- buildForegroundBody (context, constraints),
1642
+ if (innerController == null )
1643
+ buildForegroundBody (context, constraints, null )
1644
+ else
1645
+ buildInitializeWrapper (
1646
+ builder: (CameraValue v, _) => buildForegroundBody (
1647
+ context,
1648
+ constraints,
1649
+ v.deviceOrientation,
1650
+ ),
1651
+ ),
1606
1652
],
1607
1653
);
1608
1654
},
0 commit comments