Dismissible组件
/**
* 滑动删除组件
*
* const Dismissible({
@required Key key, // 必须的键值,用于区分不同的Dismissible
@required this.child, // 子组件,通常是你想要滑动删除的列表项
this.background, // 滑动时显示的背景
// 滑动时组件下一层显示的内容。没有设置secondaryBackground时,从右往左或者从左往右滑动都显示该内容。
// 设置了secondaryBackground后,从左往右滑动显示该内容,从右往左滑动显示secondaryBackground的内容。
// 注意:secondaryBackground不能单独设置,只能在已经设置了background后才能设置。
this.secondaryBackground, // 从右往左滑动时显示的背景
this.onResize, // 组件大小改变时的回调
this.onDismissed, // 组件消失后的回调
this.direction = DismissDirection.horizontal, // 滑动方向,默认为水平方向
this.resizeDuration = const Duration(milliseconds: 300), // 组件大小改变的时间
this.dismissThresholds = const <DismissDirection, double>{}, // 滑动消失的阈值
this.movementDuration = const Duration(milliseconds: 200), // 组件消失的时间
this.crossAxisEndOffset = 0.0, // 滑动结束时的偏移量
})
*/
Dismissible(
key: Key('a${index}'), // 设置key
secondaryBackground: Container( // 设置从右往左滑动时显示的背景
child: Text('左滑删除', style: TextStyle(fontSize: Screen.width(32), color: Colors.white)),
color: Colors.red,
padding: EdgeInsets.only(right: Screen.width(10)),
alignment: Alignment.centerRight,
),
background: Container( // 设置从左往右滑动时显示的背景
child: Text('右滑删除', style: TextStyle(fontSize: Screen.width(32), color: Colors.white)),
color: Colors.red,
padding: EdgeInsets.only(left: Screen.width(10)),
alignment: Alignment.centerLeft,
),
onDismissed: (direction) { // 滑动删除后的回调
print('onDismissed');
},
child: // 此处应放置子组件,例如列表项等
),