我不明白你的意思是“我不想要一个容器小部件并改变它的半径”,但这是我创建一个半圆的方法:
class Test extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Container(
padding: EdgeInsets.all(64.0),
child: new Column(
children: <Widget>[
new ClipPath(
clipper: new CustomHalfCircleClipper(),
child: new Container(
height: 300.0,
width: 300.0,
decoration: new BoxDecoration(color: Colors.blue, borderRadius: BorderRadius.circular(150.0) ),
),
)
],
),
),
);
}
}
class CustomHalfCircleClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
final Path path = new Path();
path.lineTo(0.0, size.height / 2);
path.lineTo(size.width, size.height / 2);
path.lineTo(size.width, 0);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return true;
}
}