admin管理员组文章数量:1125947
I'm using the CamerAwesome plugin in Flutter to capture images. My goal is to have a 1:1 aspect ratio for both the preview and the final captured image.
While I have set up the preview to display in 1:1, the final captured image seems slightly misaligned—it is translated downward. This makes the preview and the resulting image inconsistent.
How can I ensure that the preview and the final capture are perfectly aligned and maintain the same framing in 1:1 aspect ratio?
Any guidance or examples would be greatly appreciated. Thank you!
class CameraScreen extends StatelessWidget {
const CameraScreen({super.key});
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => CameraProvider(),
child: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CameraPreviewWidget(),
SizedBox(height: 100.w),
const CameraControlButtons(),
],
),
),
);
}
}
class CameraPreviewWidget extends StatelessWidget {
const CameraPreviewWidget({super.key});
@override
Widget build(BuildContext context) {
final previewSize = 360.w;
return Center(
child: SizedBox(
width: previewSize,
height: previewSize,
child: Consumer<CameraProvider>(
builder: (context, cameraProvider, child) {
return CameraAwesomeBuilder.custom(
saveConfig: SaveConfig.photo(),
sensorConfig: SensorConfig.single(
sensor: Sensor.position(SensorPosition.back),
aspectRatio: CameraAspectRatios.ratio_1_1,
flashMode: cameraProvider.flashMode,
zoom: 0.0,
),
builder: (cameraState, previewSize) {
return cameraState.when(
onPreparingCamera: (state) =>
const Center(child: CircularProgressIndicator()),
onPhotoMode: (state) {
cameraProvider.setCameraState(state);
return SizedBox(
width: 360.w,
height: 360.w,
);
},
);
},
);
},
),
),
);
}
}```
[![camera][1]][1]
[1]: .png
本文标签: flutterHow to align preview and captured image in 11 using CamerAwesomeStack Overflow
版权声明:本文标题:flutter - How to align preview and captured image in 1:1 using CamerAwesome? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736676035a1947184.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论