flutter-使用for循环消除flutter中的小部件

时间:2019-07-13 10:53:24

标签: flutter

创建一个解雇项目非常容易。如果我没记错的话,用解雇功能包装一个列表会启用解雇功能。但是在这里我无法这样做。任何帮助,将不胜感激。谢谢。

试图以多种方式放置dismiss函数,但无法获得所需的结果。

 Widget _loadMessages() {
        var items= List<Container>();
        for (var i=0; i<messages.length; i++) {
          var message= messages[i];
          items.add(
            new Container(
                margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
              child: new InkWell(
                child: new Card(
                  child: new SizedBox(
                    height: 140.0,
                child: new Row(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: <Widget>[
                  new Expanded(
                    child: new ListTile(
                    leading: Icon(Icons.message),
                    title: Text(message['title']),
                    subtitle: new Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Text(message['body'], style: TextStyle(fontSize: 16.0),),
                        Text(message['date'], style: TextStyle(fontSize: 10.0, color: Colors.black45),)
                      ],
                    ),
                  ),
                  ),
                  new Container( 
                    color: Colors.lightBlueAccent,
                    alignment: Alignment.center,
                    padding: const EdgeInsets.symmetric(horizontal: 6.0),
                  ),
                ],
              )),
              ))
            ));
        }
        return ListView(
          children: items,
        );
      }



 I need the returning items to be dismissed.

0 个答案:

没有答案