【发布时间】:2019-04-28 15:06:39
【问题描述】:
请我尝试创建这种效果,即当点击屏幕时 AppBar 滑出,再次点击屏幕时滑入。
我可以通过将浮动和捕捉设置为 true 在 SliverAppBar 中创建类似的东西。不同之处在于 appBar 在向下滚动时显示,在屏幕被点击或向上滚动时隐藏。
这里是 SliverAppBar 的示例代码:
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
controller: _ctrlr,
slivers: <Widget>[
SliverAppBar(
floating: true,
snap: true,
),
SliverList(
delegate: SliverChildListDelegate([
Text('1', style: TextStyle(fontSize: 160.0),),
Text('2', style: TextStyle(fontSize: 160.0),),
Text('3', style: TextStyle(fontSize: 160.0),),
Text('4', style: TextStyle(fontSize: 160.0),),
]),
)
],
),
);
}
我怎样才能做到这一点?我还考虑将 AppBar 放在 Stack 中,但我认为这不是最好的方法。非常感谢您的帮助!
【问题讨论】:
标签: android flutter dart flutter-layout