Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我接收实时数据,有时类型是 List ,有时类型是 Map<String, dynamic> ,在每种类型上,我都想执行不同的操作;我怎样才能区分它们?
你可以使用这个函数,它返回 0--> 当给定参数是 List,1--> 当给定参数是 Map,2--> 当给定参数不是 List 或 Map
int isListOrMap(var d){ if(d is List){ return 0; } if(d is Map){ return 1; } return 2; }