Reputation: 1740
I'm trying to record a video with flutter but in aspectRatio equals to 1. Here is my camera preview:
Transform.scale(
scale: 1.0,
child: AspectRatio(
aspectRatio: 1.0,
child: OverflowBox(
alignment: Alignment.center,
child: FittedBox(
fit: BoxFit.cover,
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: CameraPreview(controller!),
),
),
),
),
),
And this is my record method when the user stops recording:
XFile? rawVideo = await controller!.stopVideoRecording();
File file = File(rawVideo!.path);
int timestamp = DateTime.now().millisecondsSinceEpoch;
final directory = await getApplicationDocumentsDirectory();
String fileFormat = file.path.split('.').last;
_videoFile = await file.copy(
'${directory.path}/$timestamp.$fileFormat',
);
But the video keeps recording in portrait 16:9 aspect ratio. How can I record in 1:1 ratio?
Upvotes: 0
Views: 765
Reputation: 4331
In short, you can't with official camera plugin. You will have to crop the video post recording to get your desired result. Official camera plugin offers preset of resolutions if available on device.
For more info check out official documentation for https://pub.dev/documentation/camera_platform_interface/latest/camera_platform_interface/ResolutionPreset.htmlResolutionPreset
Upvotes: 1