zoukankan      html  css  js  c++  java
  • flutter Dismissible 可以在拖动时隐藏的widget

    import 'package:flutter/material.dart';
    
    class DismissedAppPage extends StatefulWidget {
      @override
      State<StatefulWidget> createState() {
        return new _DismissedAppPageState();
      }
    }
    
    class _DismissedAppPageState extends State<DismissedAppPage> {
      List<String> list = [
        'A',
        'B',
        'C',
        'D',
        'E',
        'F',
        'G',
        'H',
        'I',
        'J',
        'K',
        'L'
      ];
    
    
      @override
      Widget build(BuildContext context) {
    
        // TODO: implement build
        return new Scaffold(
    
          appBar: new AppBar(
            title: new Text('Dismissed 学习'),
            centerTitle: true,
          ),
          body: new ListView.builder(
              itemCount: list.length,
              itemBuilder: (context, index) {
                final String curItem = list[index];
    
                return new Dismissible(
                    key: new Key(curItem),
                    direction: DismissDirection.endToStart,
                    onDismissed: (direction) {
                      list.removeAt(index);
                      print("$curItem 被划走了");
                      final snackBar = new SnackBar(content: new Text("$curItem"));
                      Scaffold.of(context).showSnackBar(snackBar);
                    },
                    background: new Container(
                        child: new Center(
                          child: new Text('即将被删除'),
                        ),
                        color: Colors.red),
                    child: new ListTile(
                      title: new Text(curItem),
                    ));
              }),
        );
      }
    }
    
    class DismissedPage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        // TODO: implement build
        return new Scaffold(
          body: new DismissedAppPage(),
        );
      }
    }
  • 相关阅读:
    关于软件测试的浅谈
    软件测试中的压力测试和性能测试
    白盒测试一些方法
    浅谈黑盒测试
    关于判断是否为闰年以及异常处理问题
    软件测试用例
    等价类划分
    关于白盒测试
    【软件测试】软件测试方法划分
    【软件测试】灰盒测试
  • 原文地址:https://www.cnblogs.com/loaderman/p/11352189.html
Copyright © 2011-2022 走看看