Flutter 在旋转木马中一次显示两张图片
我怎么能在照片上用颤栗来做这样的东西? 我在Flatter carousel_slider 2.2.1库中搜索, 但它没有一次显示两张图片的功能Flutter 在旋转木马中一次显示两张图片,flutter,carousel,indicator,Flutter,Carousel,Indicator,我怎么能在照片上用颤栗来做这样的东西? 我在Flatter carousel_slider 2.2.1库中搜索, 但它没有一次显示两张图片的功能 Widget _buildReport() { return CarouselSlider( options: CarouselOptions( height: 150.0, autoPlay: true, autoPlayInterval: Duration(seconds: 4),
Widget _buildReport() {
return CarouselSlider(
options: CarouselOptions(
height: 150.0,
autoPlay: true,
autoPlayInterval: Duration(seconds: 4),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.fastOutSlowIn,
),
items: [1, 2, 3, 4, 5].map((i) {
return Builder(
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
child: Image(
image: AssetImage('assets/dog.jpg'),
fit: BoxFit.cover,
));
},
);
}).toList(),
);
}
您可以使用carousel使用
Row
小部件和MainAxisAlignment来执行此操作。使用Expanded
将每个图像括起来,如下所示:
Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Image.asset(
"assets/",
fit: BoxFit.cover,
),
),
Expanded(
child: Image.asset(
"assets/",
fit: BoxFit.cover,
),
),
],
),
)
正在运行的应用程序:
对两个图像/小部件使用行小部件和行内使用扩展小部件