【发布时间】:2020-08-26 08:25:24
【问题描述】:
我的页面布局是这样的:
return new Scaffold(
appBar: _getAppBarWidget(_currentIndex),
body: return CustomScrollView(slivers: [
SliverPersistentHeader(
delegate: ProfileBar(expandedHeight: 200),
pinned: true,
),
SliverToBoxAdapter(
child: ProfileView()
),
]);,
bottomNavigationBar: BottomBar(),
);
我希望我的 ProfileView 占据整个屏幕尺寸。
ProfileView() 看起来像这样:
return Container(
color: Colors.green;
child: RaisedButton(
child: const Text('Something'),
textColor: Colors.white,
color: Colors.redAccent,
onPressed: () {}
)
);
但我无法从 ProfileView 中获取我的 Container 以获取剩余在 SliverPersistentHeader 下方的屏幕高度的其余部分。
我尝试了很多不同的方法,但都没有成功。 (例如,使用 Expended)有人对此有建议吗?
编辑:我唯一成功的就是硬编码。但这不是我想要的。
【问题讨论】:
-
您是否尝试使用 SliverFillRemaining 而不是 SliverToBoxAdapter 包装 ProfileView?
-
@shubham 其实我试过这个但没有成功。但既然你提到了它,我又试了一次,我成功了。谢谢!我不知道这次我做了什么不同。
-
很高兴它对您有所帮助。我会将其发布为答案。
标签: flutter flutter-layout flutter-sliver