This package allow you to have a custom ratio for camera preview using the camera package, you can the have a square camera preview as you need.
- A CustomRatioCameraPreview widget
- A callback function that will give you you all necessary informations to perform cropping
- Install this package
flutter pub add custom_ratio_camera
- Follow the installation steps of the camera package
/// onCropData function to get cropping parameters
///
///[dx] and [dy] specify the top left corner of the output rectangle
///
/// [w] is the width of the output rectangle
///
/// [h] is the height of the output rectangle
///
///
/// example: ``` ffmpeg -i in.mp4 -filter:v "crop=w:h:dx:dy" out.mp4 ```
return CustomRatioCameraPreview(
cameraController: cameraController,
expectedRatio: 1/1,
onCropData: (dx, dy, w, h) {
print(dx);
print(dy);
print(h);
print(w);
},
);