Flutter: Dismissible 通过在指示的方向上拖动来解除的Widget

class _MyHomeState extends State<MyHome> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Flutter Demo'),
        ),
        body: ListView(
          children: <Widget>[
            Dismissible(

              background: Container(
                color: Colors.green,
                child: Align(
                  alignment: AlignmentDirectional.centerStart,
                  child: Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Icon(Icons.favorite),
                  ),
                ),
              ),

              secondaryBackground: Container(
                color: Colors.red,
                child: Align(
                  alignment: AlignmentDirectional.centerEnd,
                  child: Padding(
                    padding: EdgeInsets.only(right: 8),
                    child: Icon(Icons.delete),
                  ),
                ),
              ),

              child: ListTile(
                title: Text('aaaaaa'),
              ),

              key: ValueKey('aaaaaa'),

              onDismissed: (DismissDirection direction) {
                print(direction);
              },

            ),
          ],
        ));
  }
}
posted @ 2019-05-25 23:11  Ajanuw  阅读(317)  评论(0编辑  收藏  举报