TabBarView内容位于固定的TabBar下-SliverPersistentHeader

时间:2019-11-07 15:37:51

标签: flutter dart header tabbar flutter-sliver

我正在开发应用程序,现在正面临一个问题。问题在于TabBarView内容位于固定的TabBar(SliverPersistentHeader)和SliverAppBar下。所有图片均记录在此图片中Here is UI that I want achieve Described problem Here we can see problem clearly SliverAppBar works well

除此问题外,此UI均运行良好,我尝试将SliverPersistentHeader与SliverSafeArea和SliverOverlapAbsorber打包在一起,但它不起作用。这发生过... SliverPersistentHeader wrapped by SliverSafeArea and SliverOverlapAbsorber

SliverOverlapAbsorber(
                    handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
                        context),
                    child: SliverSafeArea(
                      bottom: false,
                      top: false,
                      sliver: SliverPersistentHeader(
                        delegate: _SliverAppBarDelegate(
                          _buildTabBar(),
                        ),
                        pinned: true,
                      ),
                    ),
                  ),


class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
  _SliverAppBarDelegate(this._tabBar);

  final PreferredSize _tabBar;

  @override
  double get minExtent => _tabBar.preferredSize.height;
  @override
  double get maxExtent => _tabBar.preferredSize.height;

  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return new Container(
      color: Colors.white,
      child: _tabBar,
    );
  }

  @override
  bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
    return false;
  }
}

在这里您可以下载我整个页面的代码 https://ufile.io/xf8qfzjn

0 个答案:

没有答案