类似iOS 的UIPageController
PageView.builder(
controller: _pageController,
itemCount: 5,
itemBuilder:(BuildContext context,int index)=>_rendRow(context, index),
scrollDirection: Axis.horizontal,
),
Widget _rendRow(BuildContext context,int index){
return new Padding(
padding: EdgeInsets.symmetric(
vertical: 30.0,
horizontal: 20.0
),
child: new GestureDetector(
onTap: (){
Scaffold.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.deepOrangeAccent,
duration: Duration(milliseconds: 800),
content: Text(
"222",
// descriptions[index],
style: TextStyle(fontSize: 25.0),
),
));
},
child: new Material(
elevation: 5.0,
child: new Container(
color: Colors.deepOrange,
child: new Text("$index"),
),
),
)
);
}
_pageController = PageController(
viewportFraction: 0.8
);
viewportFraction:占屏幕比例
网友评论