Я пытаюсь использовать показ элемента CustomPaint поверх предварительного просмотра камеры во Flutter.Прямо сейчас элемент CustomPaint отображается под предварительным просмотром камеры.Я использую плагин Flutter для камеры , чтобы показать предварительный просмотр камеры.Мой код ниже.
class _CameraPreviewState extends State<CameraPreview> {
[...]
Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height;
return new YidKitTheme(
new Center(
child: _isReady
? new Container(
height: height / 2,
child: new CustomPaint(
painter: new GuidelinePainter(),
child: new AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: new CameraPreview(controller)
),
)
)
: new CircularProgressIndicator()
)
);
}
}
class GuidelinePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = new Paint()
..strokeWidth = 3.0
..color = Colors.red
..style = PaintingStyle.stroke;
var path = new Path()..lineTo(50.0, 50.0);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => true;
}