小编Ahm*_*met的帖子

如何更改 Sliver 持久标头的固定

我在 GridView 上方使用 2 个 Sliver header,在 CustomScrollView 上使用 ListView 。当我向下滚动时,我只希望固定 1 个标题(我正在滚动的标题)。我希望能够向下滚动,并且当我经过 Gridview 时,只有一个标题被固定。

编辑:添加 _SliverAppBarDelegate

Scaffold(
body: SafeArea(
        child: DefaultTabController(
          length: 2,
          child: CustomScrollView(
            slivers: [              
              makeHeader('Categories', false),
              SliverGrid(
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2,
                  childAspectRatio: 1.5,
                ),
                delegate: SliverChildBuilderDelegate(
                    (context, index) => Container(
                          margin: EdgeInsets.all(5.0),
                          color: Colors.blue,
                        ),
                    childCount: 10),
              ),
              makeHeader('Watchlist', false),
              SliverGrid(
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2,
                  childAspectRatio: 1.5,
                ),
                delegate: SliverChildBuilderDelegate(
                    (context, index) => Container(
                          margin: EdgeInsets.all(5.0),
                          color: Colors.red,
                        ),
                    childCount: 10),
              ),
            ],
          ),
        ),
  ), …
Run Code Online (Sandbox Code Playgroud)

flutter

6
推荐指数
1
解决办法
6785
查看次数

标签 统计

flutter ×1