Flutter移除清单项目 [英] Flutter Remove list item

查看:70
本文介绍了Flutter移除清单项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的飞镖脚本中有一个问题,这是我的脚本:

  List< ReplyTile>Replytile =新的List< ReplyTile>();Replytile.add(新的ReplyTile(member_photo:照片",member_id:"001",日期:"2018年1月1日",member_name:丹尼斯",id:"001",文字:你好.")); 

我的问题是:如何使用 id = 001 删除 List< ReplyTile> 上的项目.

预先感谢

解决方案

removeWhere 允许这样做:

  replytile.removeWhere((item)=> item.id =='001') 

另请参见列出Dartdoc

I have a question in my flutter dart script, this my script:

List<ReplyTile> replytile = new List<ReplyTile>();

replytile.add(
    new ReplyTile(
        member_photo: "photo",
        member_id: "001",
        date: "01-01-2018",
        member_name: "Denis",
        id: "001",
        text: "hallo.."
    )
);

My question is: how to remove items on List<ReplyTile> with id = 001.. ?

Thanks in advance

解决方案

removeWhere allows to do that:

replytile.removeWhere((item) => item.id == '001')

See also List Dartdoc

这篇关于Flutter移除清单项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆