Flutter 颤振拉环
请告诉我,我正在尝试在颤振中使用自定义绘画绘制一个环,有没有关于如何实现它的想法 当我试图这样实现它时,但它没有被接受,因为我需要影子更专业:Flutter 颤振拉环,flutter,Flutter,请告诉我,我正在尝试在颤振中使用自定义绘画绘制一个环,有没有关于如何实现它的想法 当我试图这样实现它时,但它没有被接受,因为我需要影子更专业: Stack( alignment: Alignment.center, children: [ Container( height: 180,
Stack(
alignment: Alignment.center,
children: [
Container(
height: 180,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 2,
spreadRadius: 1,
offset: Offset(0, 2)),
],
),
),
Container(
height: 150,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 2,
spreadRadius: 1,
offset: Offset(0, 2)),
],
),
),
],
),
是的,它可以很容易地完成使用自定义油漆
class MyHome extends StatelessWidget{
@override
Widget build(BuildContext context){
return Scaffold(
body: Center(
child: Container(
height:200,
width:200,
child:CustomPaint(
painter:RingPainter(),
),
),
),
);
}
}
class RingPainter extends CustomPainter{
@override
void paint(Canvas canvas, Size size) {
double height=size.height;
double width=size.width;
//Paint to draw ring shape
Paint paint=Paint()..color=Colors.green..strokeWidth=16.0
..style=PaintingStyle.stroke..strokeCap=StrokeCap.round;
//defining Center of Box
Offset center=Offset(width/2,height/2);
//defining radius
double radius=min(width/2,height/2);
canvas.drawCircle(center,radius,paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}
可以和我们分享一下,你的成绩画(成绩图)你想要吗?