Commit 6ae1e7c8 authored by Dio Maulana's avatar Dio Maulana

jarak swithc camera

parent 330cbc50
......@@ -353,121 +353,127 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
),
],
)
: Row(
mainAxisAlignment:
MainAxisAlignment.center,
: Stack(
children: [
// GestureDetector(
// onTap: () {
// if (flashMode ==
// FlashMode.always) {
// flashMode = FlashMode.off;
// } else {
// flashMode = FlashMode.always;
// }
// setState(() {
// _controller!
// .setFlashMode(flashMode);
// });
// },
// child: Icon(
// Icons.flash_auto,
// size: 35,
// color: ColorManager.primary,
// ),
// ),
const SizedBox(
width: 35,
),
const SizedBox(
width: 20,
),
InkWell(
onTap: () async {
try {
await _initializeControllerFuture;
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
// GestureDetector(
// onTap: () {
// if (flashMode ==
// FlashMode.always) {
// flashMode = FlashMode.off;
// } else {
// flashMode = FlashMode.always;
// }
// setState(() {
// _controller!
// .setFlashMode(flashMode);
// });
// },
// child: Icon(
// Icons.flash_auto,
// size: 35,
// color: ColorManager.primary,
// ),
// ),
const SizedBox(
width: 100,
),
InkWell(
onTap: () async {
try {
await _initializeControllerFuture;
// ambil imagenya
XFile image = await _controller!
.takePicture();
String? imageResultPhone;
Uint8List? imageResultWeb;
if (isPhone) {
imageResultPhone = image.path;
imageResultWeb =
await image.readAsBytes();
} else {
imageResultWeb =
await image.readAsBytes();
}
// ambil imagenya
XFile image =
await _controller!
.takePicture();
String? imageResultPhone;
Uint8List? imageResultWeb;
if (isPhone) {
imageResultPhone =
image.path;
imageResultWeb = await image
.readAsBytes();
} else {
imageResultWeb = await image
.readAsBytes();
}
// kalau gak ke ambil gak ngelakuin aksi apa2
if (!mounted) return;
setState(() {
pictureIsTaken = true;
imagePath = imageResultWeb;
imagePathPhone =
imageResultPhone;
imageBase64 = base64Encode(
imageResultWeb!);
});
} catch (e) {
if (debug) {
// ignore: avoid_print
print(
"TERJADI KESALAHAAN SAAT AMBIL GAMBER, ERROR: $e");
}
}
},
child: Container(
width: 80,
height: 80,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(100),
border: Border.all(
width: 1.5,
color: Colors.black,
// kalau gak ke ambil gak ngelakuin aksi apa2
if (!mounted) return;
setState(() {
pictureIsTaken = true;
imagePath = imageResultWeb;
imagePathPhone =
imageResultPhone;
imageBase64 = base64Encode(
imageResultWeb!);
});
} catch (e) {
if (debug) {
// ignore: avoid_print
print(
"TERJADI KESALAHAAN SAAT AMBIL GAMBER, ERROR: $e");
}
}
},
child: Container(
width: 80,
height: 80,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(
100),
border: Border.all(
width: 1.5,
color: Colors.black,
),
color: Colors.red,
),
),
color: Colors.red,
),
),
),
const SizedBox(
width: 20,
),
GestureDetector(
onTap: () {
if (cameras!.length > 1) {
setState(() {
if (_cameraDescription ==
cameras![0]) {
_cameraDescription =
cameras![1];
} else {
_cameraDescription =
cameras![0];
}
const SizedBox(
width: 60,
),
GestureDetector(
onTap: () {
if (cameras!.length > 1) {
setState(() {
if (_cameraDescription ==
cameras![0]) {
_cameraDescription =
cameras![1];
} else {
_cameraDescription =
cameras![0];
}
_controller = CameraController(
// Get a specific camera from the list of available cameras.
_cameraDescription!,
// Define the resolution to use.
ResolutionPreset.medium,
imageFormatGroup:
ImageFormatGroup.jpeg,
);
_initializeControllerFuture =
_controller!.initialize();
});
}
},
child: Icon(
Icons.switch_camera_outlined,
size: 35,
color: ColorManager.primary,
),
)
_controller =
CameraController(
// Get a specific camera from the list of available cameras.
_cameraDescription!,
// Define the resolution to use.
ResolutionPreset.medium,
imageFormatGroup:
ImageFormatGroup.jpeg,
);
_initializeControllerFuture =
_controller!
.initialize();
});
}
},
child: Icon(
Icons.switch_camera_outlined,
size: 35,
color: ColorManager.primary,
),
)
],
),
],
),
const SizedBox(
......
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