首页 > 解决方案 > Flutter How to remove white blank between sliverappbar and sliverList when pull down sliverlist?

问题描述

I'd like to do sync pull down for SliverAppBar together with SliverList but when pull down the SliverList, there comes a white blank between these 2 widgets.

Does anyone knows how to remove the padding between them? Thanks a lot.

What I mean is how to set SliverAppBar and SliverList always stick to each other.

Scaffold(
        body: CustomScrollView(controller: controller, slivers: [
      SliverAppBar(
        // pinned: true,
        // floating: true,
        flexibleSpace: FlexibleSpaceBar(
            background: HomeTopBar(
              picHeightExtra: picHeightExtra,
              fitMode: fitMode,
            )),
        expandedHeight: 500 + picHeightExtra,
      ),
      SliverList(
        delegate: SliverChildBuilderDelegate((context, index) {
          return Container(
            height: 50,
            color: Colors.blueAccent,
          );
        }, childCount: 30, addRepaintBoundaries: false),
      ),
    ]));

image for SliverAppBar and SliverList

标签: flutterflutter-layoutflutter-sliver

解决方案


终于找到答案了……

需要将 CustomScrollView 的物理特性更改为 ClampingScrollPhysics 并且“顶部”小部件不会有空白。


推荐阅读