change size camere 9:16
This commit is contained in:
parent
650e17012f
commit
04383690d1
|
|
@ -55,6 +55,35 @@ class _CameraScreenState extends State<CameraScreen> {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget buildCameraPreview() {
|
||||||
|
final previewSize = controller?.value.previewSize;
|
||||||
|
if (previewSize == null) {
|
||||||
|
return CameraPreview(controller!);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kamera biasanya memberikan rasio landscape, ubah ke portrait 9:16
|
||||||
|
final double previewAspectRatio = previewSize.height / previewSize.width;
|
||||||
|
|
||||||
|
return Center(
|
||||||
|
child: AspectRatio(
|
||||||
|
aspectRatio: 9 / 16,
|
||||||
|
child: ClipRect(
|
||||||
|
child: OverflowBox(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
child: SizedBox(
|
||||||
|
width: previewSize.width,
|
||||||
|
height: previewSize.width / previewAspectRatio,
|
||||||
|
child: CameraPreview(controller!),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (controller == null || !controller!.value.isInitialized) {
|
if (controller == null || !controller!.value.isInitialized) {
|
||||||
|
|
@ -68,7 +97,7 @@ class _CameraScreenState extends State<CameraScreen> {
|
||||||
children: [
|
children: [
|
||||||
// 📷 PREVIEW KAMERA (FULL SCREEN)
|
// 📷 PREVIEW KAMERA (FULL SCREEN)
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: CameraPreview(controller!),
|
child: buildCameraPreview(),
|
||||||
),
|
),
|
||||||
|
|
||||||
// 🔙 TOMBOL KEMBALI (KANAN BAWAH)
|
// 🔙 TOMBOL KEMBALI (KANAN BAWAH)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue