如何添加分页功能SliverList

时间:2018-09-12 14:44:26

标签: flutter

我已经在SliverList中加载了一些新闻。我想使该列表动态化。如何在下面的代码中使用SliverList添加分页功能?

FutureBuilder<List<Data>>(
    future: getNews(),
    builder: (context, snapshot){
      Widget newsListSliver;

      if(snapshot.hasData){
        newsListSliver = SliverList(

          delegate: new SliverChildBuilderDelegate((context, index){
            return new NewsList(latestNews: snapshot.data.elementAt(index),);
          }, childCount: snapshot.data.length),
        );
      }else{
        newsListSliver = SliverToBoxAdapter(child: Center(child: CircularProgressIndicator(),));
      }
      return CustomScrollView(
        slivers: <Widget>[

          SliverToBoxAdapter(child: new TabPanel()),
          SliverToBoxAdapter(child: new UrlButtonPanel()),
          SliverToBoxAdapter(child: new ChatNowAd()),

          newsListSliver
        ],
      );
    },
  )

0 个答案:

没有答案