flutter - 如何用颤动的条子做动画切换器
问题描述
所以我有一个带有 a的SliverAppBar(floating: true, snap: true)
CustomScrollView 。SliverPersistentHeader(pinned: true)
SliverList
我想要做的是单击标题中的一个按钮,然后在 and 占用的空间中弹出一个小SliverPersistentHeade
部件SliverList
。我尝试将它们放在 a nestedScrollView
and 嵌套SliverPersistentHeader
和SliverList
另一个 scrollView 内,但由于SliverAppBar
and不在一起,它会在 it( ) 快速启动和关闭SliverPersistentHeader
时弄乱预期的效果。SliverAppBar
为什么我需要这样:我想用 appBar 中的元素执行一些动画,因为两个页面之间的下部过渡有点像animtions 共享轴包
问题
- 将persistantHeader保留在第一页
- 保持 snap 浮动 appbar 功能
- 过渡下半部分
注意:答案不一定需要依赖条子。实现这一目标的可能方法
我现在的代码大致是这样的
CustomScrollView(
physics: BouncingScrollPhysics(),
slivers: [
SliverAppBar(
backgroundColor: Colors.white,
floating: true,
snap: true,
titleSpacing: 0,
elevation: 4,
title: Row(
children: [
Expanded(
child: Container(
padding: EdgeInsets.only(top: 10, bottom: 10, left: 10),
child: Container(color: Colors.grey),
),
),
),
Container(
child: LeadingButton(
color: lightShadeColor,
icon: Icons.qr_code_scanner_rounded,
iconColor: darkColor,
size: 37, // btnShadow: false
),
),
],
),
),
SliverPersistentHeader(
delegate: PersistentHeader(
widget: Row(
// Format this to meet your need
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
padding: EdgeInsets.all(10),
child: Text('data'),
)
],
),
),
pinned: true,
),
SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
return ListTile(
title: Text('index $index'),
);
}),
)
],
),
解决方案
推荐阅读
- c++ - 如何使用divides和for_each?
- reactjs - TypeError:无法使用 Jest 和 React 读取未定义道具的属性“电子邮件”。为什么?
- javascript - 无法设置 fetch() 之外的变量的 innerHTML
- javascript - 两位数30秒倒计时
- centos - 在同一局域网中公开 Ngrok Web 界面
- ascii - 在雪花中创建文件格式
- python - 将 Pandas 系列的 Dataframe 作为一个整体而不是元素进行比较
- blazor - 何获取自定义 Blazor 组件的特定实例
- php - 致命错误:第 36 行的 /home/... 中没有活动的类范围时无法使用“self”
- html - 如何将选择标签的选项向右移动?