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

原文链接: http://www.cnblogs.com/ajanuw/p/10924471.html
  • API
class _MyHomeState extends State {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Flutter Demo'),
        ),
        body: ListView(
          children: [
            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);
              },

            ),
          ],
        ));
  }
}

转载于:https://www.cnblogs.com/ajanuw/p/10924471.html

你可能感兴趣的:(Flutter: Dismissible 通过在指示的方向上拖动来解除的Widget)