Home > Back-end >  Remove item from list flutter
Remove item from list flutter

Time:07-12

I have code using flutter, and have the following list

var data = [
      {
         'label' : '0.25x',
         'value' : '0.25'
       },
      {
         'label' : '1.0x',
         'value' : '1'
       },
      {
         'label' : '1.25x',
         'value' : '1.25'
       },
{
         'label' : '1.5x',
         'value' : '1.5'
       },
];

I want to delete the above data whose values are in this array

final removedData = [1.25, 1.5];

how can i delete it?

CodePudding user response:

data.map((e) => e['value']?.contains(removedData.toString())).toList();

CodePudding user response:

Use removeWhere

data.removeWhere((data) => removedData.contains(data.value));
  • Related