Reputation: 1
If I receive real-time data, sometimes the type is List , and sometimes the type is Map<String, dynamic>, and on each type, I want to perform different operations; how can I differentiate them?
Upvotes: 0
Views: 38
Reputation: 26
you can use this function , it return 0--> when given argument is List,1 --> when given argument is Map, 2--> when given argument is no List or Map
int isListOrMap(var d){
if(d is List){
return 0;
}
if(d is Map){
return 1;
}
return 2;
}
Upvotes: 0