我在为todo应用程序设计要在flutter中删除的滑动时遇到问题这就是我尝试过的:
Container(
width:MediaQuery.of(context).size.width *0.90,
child:Card(
elevation: 0,
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(20.0),
),
child: Slidable(
secondaryActions: <Widget>[
SlideAction(
child: Container(
width: MediaQuery.of(context)
.size
.width *
0.50,
height: MediaQuery.of(context)
.size
.height *
0.13,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius:
BorderRadius.circular(10),
),
child: Text(
'Delete',
),
))
],
actionPane: SlidableDrawerActionPane(),
child:Card(child:Text('Delete')
)
目前看起来是这样的:
目前的样子
但我希望它看起来像这样:通缉待办事项应用程序设计
you can try change action:SlidableScrollActionPane().There are few
other option available .
根据您的设计更改第二个解决方案背景
Dismissible(
key: Key(UniqueKey().toString()),
direction: DismissDirection.horizontal,
onDismissed: (direction) {
},
background: Container(
alignment: AlignmentDirectional.centerEnd,
color: Colors.red,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(0.0, 0.0, width*0.02, 0.0),
child: new SvgPicture.asset(
'assets/images/delete.svg',
height: width*0.05,
width: width*0.05,
color: Colors.white,
allowDrawingOutsideViewBox: true,
),
),
Container(
margin: EdgeInsets.fromLTRB(0.0, 0.0, width*0.05, 0.0),
child: Text(
"Delete".toUpperCase(),
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w600),
),
),
],
)),
child:)
尝试使用带有确认参数的可解雇小部件。如果下面的代码在中有帮助,请告诉我
Dismissible(
background: Container(color: Colors.red),
key: Key(item),
onDismissed: (direction) {
setState(() {
items.removeAt(index);
});
Scaffold
.of(context)
.showSnackBar(SnackBar(content: Text("$item dismissed")));
},
child: ListTile(title: Text('$item')),
);