切り取って複数の画面に表示したい画像があります。画像の 3 分の 1 が画面全体を占めるようにします。
これまでのところ、画像の 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が画面全体を占めるようにする方法について銀行を描いています。