如何使用 CustomScrollView 构建布局,使得底部块:
不想使用 LayoutBuilder,因为块的内容可能会有所不同,例如取决于字体大小、显示的内容等。
此外,内容可能会显示在模态底部表单中,因此在包裹整个 CustomScrollView 的可滚动环境中。我们可以访问模态底部表单的控制器。
CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Container(
height: 100,
color: Colors.blue,
),
),
SliverToBoxAdapter(
child: Container(
height: 300,
color: Colors.green,
),
),
SliverToBoxAdapter(
child: Container(
height: 300,
color: Colors.orange,
child: Center(
child: Text(
'Keep me either aligned to the bottom or in-line with other slivers'),
),
),
),
],
),
不确定是否可以在 CustomScrollView 中实现这一目标。
这是一个可能有帮助的解决方法
CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Container(
height: 100,
color: Colors.blue,
),
),
SliverToBoxAdapter(
child: Container(
height: 300,
color: Colors.green,
),
),
SliverFillRemaining(
child: Container(
height: 300,
color: Colors.orange,
child: Center(
child: Text(
'Keep me either aligned to the bottom or in-line with other slivers'),
),
),
)
],
)