我有一张想要剪切并在多个屏幕上显示的图像。我希望图像的三分之一占据整个屏幕。
到目前为止,我可以让 1/3 的图像占据 1/3 的屏幕:
Widget buildBGImage(String imageName) {
return new Container(
decoration: new BoxDecoration(border: new Border.all()),
constraints: new BoxConstraints.expand(),
child: new SizedBox.expand(
child: new ClipRect(
clipper: new WidthClipper(currentPage),
child: new Image.asset(
"assets/images/$imageName",
fit: ImageFit.fill)
)
),
);
}
class WidthClipper extends CustomClipper<Rect> {
int section;
WidthClipper(this.section);
@override
Rect getClip(Size size) {
return new Rect.fromLTWH(
size.width * (section / 3), 0.0, size.width / 3, size.height);
}
@override
bool shouldReclip(WidthClipper oldClipper) => true;
}
但我正在画一个关于如何让 1/3 占据整个屏幕的银行。