gpt4 book ai didi

flutter - 使用灵活的 SliverAppBar 作为非顶级元素

转载 作者:IT王子 更新时间:2023-10-29 07:23:54 26 4
gpt4 key购买 nike

我正在尝试在自定义应用栏下方显示一个灵活的 SliverAppBar(假设它是一个高度为 80.0 的容器)。

当将 SliverAppBar 设置为顶部元素时,它工作正常,但当它是第二个时,顶部填充与 Android UI 界面一样大。

 Scaffold(
body: Column(children: <Widget>[
Container(height: 80.0),
Expanded(child: _content())
]),
);

_content()

return CustomScrollView(slivers: <Widget>[
SliverAppBar(
backgroundColor: Colors.red,
leading: PopContentButton(),
title: Text('Test'),
snap: true,
pinned: true,
floating: true,
bottom: TabBar(
tabs: _tabs(),
controller: TabControllerExtended(length: 4, vsync: this),
),
),
SliverList(delegate: new SliverChildListDelegate(buildTextViews(50)))
]);

这不是它应该的样子: wrong
(来源:bilder-upload.eu)

它应该是这样的: right
(来源:bilder-upload.eu)

最佳答案

MediaQuery.removePadding 包装你 - SliverAppBar

更新代码:

....
MediaQuery.removePadding(
context: context,
removeTop: true,
child: SliverAppBar(
...

关于flutter - 使用灵活的 SliverAppBar 作为非顶级元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54035878/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com