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

jarak swithc camera

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