【Flutter组件】为左滑动作组件增加了弹性效果与联动关闭
文章目录
组件
这是一个仿iOS(微信)效果的 Flutter 左滑菜单插件。在最新版本中,我添加了拉伸的弹性效果。
Pub地址:left_scroll_actions
GitHub地址:left_scroll_actions
特性
弹性 (1.5.0)
- 设置
CupertinoLeftScroll的bounce参数为true,即可获得弹性效果 - 通过
CupertinoLeftScroll的bounceStyle参数控制弹性效果 - 暂时没有实现iOS的惯性效果,欢迎能实现的兄弟提出pr
联动列表(1.3.0)
这功能可以让你在打开一个左滑组件时,联动关闭其他打开的左滑组件。你也可以指定让一个组件打开与关闭:
- 对于提供同一个
LeftScrollCloseTag的LeftScroll组件,可以在一个打开时,关闭其他组件 - 想要关闭特定的行,只需使用以下代码
// 找到对应tag与key的row状态,改变状态即可
LeftScrollGlobalListener.instance.targetStatus(tag,key) = false;
例子:CupertinoLeftScroll (1.5.0)
CupertinoLeftScroll(
// important, each Row must have different key.
// DO NOT use '$index' as Key! Use id or title.
key: Key('TODO: your key'),
// left scroll widget will auto close while the other widget is opened and has same closeTag.
// 当另一个有相同closeTag的组件打开时,其他有着相同closeTag的组件会自动关闭.
closeTag: LeftScrollCloseTag('TODO: your tag'),
buttonWidth: 80,
bounce: true,
child: Container(
height: 60,
color: Colors.white,
alignment: Alignment.center,
child: Text('👈 Try Scroll Left'),
),
buttons: <Widget>[
LeftScrollItem(
text: 'edit',
color: Colors.orange,
onTap: () {
print('edit');
},
),
LeftScrollItem(
text: 'delete',
color: Colors.red,
onTap: () {
print('delete');
},
),
],
onTap: () {
print('tap row');
},
);

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论