美文网首页
flutter-pageview

flutter-pageview

作者: 磊简单 | 来源:发表于2018-08-23 12:18 被阅读0次

    类似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

          本文链接:https://www.haomeiwen.com/subject/etvpiftx.html