Flutter 获取容器获取标题下方屏幕的剩余空间

Flutter 获取容器获取标题下方屏幕的剩余空间,flutter,flutter-layout,flutter-sliver,Flutter,Flutter Layout,Flutter Sliver,我的页面布局如下: return new Scaffold( appBar: _getAppBarWidget(_currentIndex), body: return CustomScrollView(slivers: [ SliverPersistentHeader( delegate: ProfileBar(expandedHeight: 200), pinned: true, ),

我的页面布局如下:

return new Scaffold(
  appBar: _getAppBarWidget(_currentIndex),
  body: return CustomScrollView(slivers: [
          SliverPersistentHeader(
            delegate: ProfileBar(expandedHeight: 200),
            pinned: true,
          ),
          SliverToBoxAdapter(
            child: ProfileView()
          ),
      ]);,
  bottomNavigationBar: BottomBar(),
);
return Container(
  color: Colors.green;
  child: RaisedButton(
    child: const Text('Something'),
    textColor: Colors.white,
    color: Colors.redAccent,
    onPressed: () {}
  )
);
我想让我的ProfileView占据剩下的全部屏幕尺寸

ProfileView()
如下所示:

return new Scaffold(
  appBar: _getAppBarWidget(_currentIndex),
  body: return CustomScrollView(slivers: [
          SliverPersistentHeader(
            delegate: ProfileBar(expandedHeight: 200),
            pinned: true,
          ),
          SliverToBoxAdapter(
            child: ProfileView()
          ),
      ]);,
  bottomNavigationBar: BottomBar(),
);
return Container(
  color: Colors.green;
  child: RaisedButton(
    child: const Text('Something'),
    textColor: Colors.white,
    color: Colors.redAccent,
    onPressed: () {}
  )
);
但我无法从ProfileView中获取容器,以获取SliverPersistentHeader下方剩余的整个屏幕高度

我尝试了很多不同的事情,但没有成功。(例如,使用Expended)有人对此有建议吗


编辑:我唯一成功的就是硬编码。但这不是我想要的。

要解决此问题,可以使用SliverFillRestaining而不是SliverToBoxAdapter

因此,您的更新代码将

return new Scaffold(
appBar: _getAppBarWidget(_currentIndex),
body: return CustomScrollView(slivers: [
      SliverPersistentHeader(
        delegate: ProfileBar(expandedHeight: 200),
        pinned: true,
      ),
      SliverFillRemaining(
        child: ProfileView()
      ),
  ]);,
bottomNavigationBar: BottomBar(),
);

您是否尝试过用SliverFillResisting而不是SliverToBoxAdapter包装您的ProfileView?@shubham实际上我尝试过,但没有成功。但是现在你提到了,我又试了一次,我成功了。非常感谢。我不知道这次我做了什么不同。很高兴它帮助了你。我将把它作为一个答案发布。