I want to build a swiper. And then limit its height and width. Code like this.
Container(
height: 150,
width: 350,
child: Swiper(
itemBuilder: (BuildContext context, int index) {
return new Image.network(
"http://via.placeholder.com/350x150",
fit: BoxFit.fill,
);
},
itemCount: 3,
pagination: SwiperPagination(),
control: SwiperControl(),
),
);
In this case, the final render view will be like this.
And I find out if I use a Center widget wrap the Container widget that will work.
Center(child: Container(
height: 150,
width: 350,
child: Swiper(
itemBuilder: (BuildContext context, int index) {
return new Image.network(
"http://via.placeholder.com/350x150",
fit: BoxFit.fill,
);
},
itemCount: 3,
pagination: SwiperPagination(),
control: SwiperControl(),
),
),)