1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] how to get values from map based on condition in flutter dart?

Discussão em 'Mobile' iniciado por Stack, Outubro 1, 2024 às 07:12.

  1. Stack

    Stack Membro Participativo

    Using map.entries property i want to fetch all values those are even in a map data,

    I have any other solutions to get this output but i want it to solve it with map.entries property...

    its return null when value is not even

    output should be [2,4] instead of [null,2,null,4]

    void main() {
    final myMap={
    'first':1,
    'second':2,
    'three':3,
    'four':4,
    };

    List<dynamic> list=[];

    list=myMap.entries.map((e) {
    if(e.value%2==0)
    return e.value;

    }).toList();
    print(list);



    }

    Continue reading...

Compartilhe esta Página