[英]How to make a rounded Camera Preview in flutter
My Goal is to create Circle Shape with the Camera Preview.我的目标是使用相机预览创建圆形。 I tried setting a Container with Boxshape.circle and a Child : The CameraPreview().我尝试使用 Boxshape.circle 和 Child 设置一个容器:CameraPreview()。 But it didn't work.但它没有用。 So i tried setting The CameraPreview() in a CircleAvatar(), but it didn't work too.所以我尝试在 CircleAvatar() 中设置 The CameraPreview(),但它也不起作用。 Does anyone have a Solution?有没有人有办法解决吗?
Wrap the camera preview with a ClipRRect with its border-radius property defined to determine the curvature of the rounded corners: 用ClipRRect包裹相机预览,并定义其border-radius属性以确定圆角的曲率:
ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
topRight: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
),
child: AspectRatio(
aspectRatio: 1,
child: CameraPreview(controller),
),
)
My Goal is to create Circle Shape with the Camera Preview我的目标是使用相机预览创建圆形
CameraPreview
(from the Flutter Camera package) provides a series of images (or video). CameraPreview
(来自Flutter Camera包)提供了一系列图像(或视频)。 And images can be shaped with clipping (such as ClipRect
, ClipRRect
, ClipOval
, or ClipPath
).图像可以通过剪裁(例如ClipRect
、 ClipRRect
、 ClipOval
或ClipPath
)进行ClipPath
。
For a "Circle Shape" you can use ClipOval
as seen in the code below:对于“圆形”,您可以使用ClipOval
如下面的代码所示:
ClipOval(
child: CameraPreview(controller)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.