滚动Listview时出现Flutter更改选项卡

时间:2019-02-28 09:02:52

标签: listview flutter

我有Tabbar和TabView,Tabview中有单独的ListView,ListView中有Gridview,并且我想在将ListView向下滚动到下一部分时更改所选的标签栏,我该如何实现?

return Scaffold(
      appBar:
      ...
      body:
      TabBarView(controller: tabController, children: <Widget>[
        ListView.separated(
          controller: _controller,
          separatorBuilder: (context, int index) {
            return Container(
              height: 50,
              color: Colors.cyan,
              child: Center(child: Text(index.toString(),
                style: TextStyle(color: Colors.white, fontSize: 18,),)),
            );
          },
          // shrinkWrap: true,
          itemBuilder: (BuildContext context, int index) {
            return GridView.count(
              shrinkWrap: true,
              crossAxisCount: 3,
              childAspectRatio: 2.0,
              physics: NeverScrollableScrollPhysics(),
              children:
              List.generate(6, (index) {
                return
                  Center(
                    child: RaisedButton(
                      onPressed: () {},
                      color: Colors.greenAccent,
                      child: Text(
                        '$index AM',
                      ),
                    ),
                  );
              }),
            );
          },
          itemCount: 8,
        ),
      ]),
    );

enter image description here

0 个答案:

没有答案