flutter - Appbar 隐藏/显示类似 iOS 风格
问题描述
当 ListVIew 的第一个子项像 iOS 样式一样滚动时,我想显示 AppBar(尤其是 iOS 中本机 Books 应用程序中的行为)。iOS 中的许多应用程序确实具有此功能,因此我认为这是 iOS 中的常见行为。但我不知道如何将它应用到具有 Material Style 的 Flutter 中。有谁知道这个的解决方案?下面的 GIF 显示了我想要实现的 行为:Appbar iOS 风格的行为
解决方案
是的,您可以在 MaterialApp 中通过在脚手架的主体部分使用 SliverAppBar 和 CustomScrollView 来完成。您可以使用 SliverAppBar 代替普通的 appBar 您将使用的小部件应该在
SliverList(delegate: SliverChildListDelegate( [ ]))内
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
expandedHeight: 300,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
title: Text(
"Reading Now",
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.end,
),
background: Image.network(
https://i.stack.imgur.com/1lN0b.png,
fit: BoxFit.fill,
),
),
),
SliverList(
delegate: SliverChildListDelegate(
[
//widgets which you are going to use inside the listview you can use them in
//sliverList
]
),//SliverChildListDelegate
),//SliverList
],//sliver Widgets
),//customScrollView
推荐阅读
- c++ - C++ 在不停止无限循环的情况下获取用户输入
- apache-poi - 如何使用 XlsxBuilder apache poi 添加背景颜色和过滤器
- c - 在 C 中返回 WCHAR[]
- iis - 如何将 API 取消令牌与 IIS 重写和多个网站一起使用?
- python - DynamoDB 按嵌套数组查询
- flutter - 如何通过一项建议将数据转储到 2 个以上的文本字段中?[扑]
- node.js - 如何从 youtube-dl 获取视频作为响应?
- firefox - 关于:Firefox 的配置设置的解释
- java - 在 Maven 阶段使用 JaCoCo 的最佳方式是什么?
- python - 烧瓶中的PDF注释