Riana Deana
Riana Deana

Reputation: 65

Remove item from list flutter

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?

Upvotes: 0

Views: 527

Answers (2)

Vishnudev Krishnadas
Vishnudev Krishnadas

Reputation: 10960

Use removeWhere

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

Upvotes: 0

Lou
Lou

Reputation: 113

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

Upvotes: 2

Related Questions