I have an image that I want to cut and display on multiple screens. I want 1 thrid image to be full screen.
So far, I can get 1/3 of the image to occupy 1/3 of the screen with:
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;
}
but I draw a bank on how to make 1/3 take up the whole screen.
source
share