Commit de7b5fce authored by Dio Maulana's avatar Dio Maulana

perbaikan kamera

parent fbf99e2a
......@@ -790,23 +790,35 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
GestureDetector(
onTap: () async {
if (cameras!.length > 1) {
_controller
?.dispose()
.then((value) {
setState(() {});
CameraDescription? switchTo;
if (_cameraDescription ==
cameras![0]) {
_cameraDescription =
cameras![1];
switchTo = cameras![1];
} else {
_cameraDescription =
cameras![0];
switchTo = cameras![0];
if (_cameraDescription!
.lensDirection ==
CameraLensDirection.front) {
for (int i = 0;
i < cameras!.length;
i++) {
// detect only fornt camera
if (cameras![i].lensDirection ==
CameraLensDirection.back) {
_cameraDescription =
cameras![i];
}
}
} else {
for (int i = 0;
i < cameras!.length;
i++) {
// detect only fornt camera
if (cameras![i].lensDirection ==
CameraLensDirection.front) {
_cameraDescription =
cameras![i];
}
}
}
_controller?.dispose().then((_) {
setState(() {});
_controller = CameraController(
switchTo,
_cameraDescription!,
ResolutionPreset.medium,
imageFormatGroup:
ImageFormatGroup.jpeg,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment