flutter-pageview

类似iOS 的UIPageController

  • 构建
PageView.builder(
          controller: _pageController,
          itemCount: 5,
          itemBuilder:(BuildContext context,int index)=>_rendRow(context, index),
          scrollDirection: Axis.horizontal,
        ),
  • 构建row
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 = PageController(
      viewportFraction: 0.8
    );
viewportFraction:占屏幕比例

你可能感兴趣的:(flutter-pageview)