[英]How to call a function which takes parameter of type Map in dart?
I want to know the execution in case of Map.我想知道 Map 的执行情况。
void main(){
var info = userInfo(); /* what can I pass here as args? */
print(info);
}
userInfo(Map user){
/* what do I write here? */
}
hi there you can pass a map and use the map as follow您好,您可以通过 map 并使用 map 如下
void main(){
Map user_map=
{
"first_name" : "fname",
"last_name" : "lname",
"gender" : "male",
"location" :
{ "state" : "state",
"country" : "country",
"place" : "place"
}
}
var info = userInfo(user_map); /* what can I pass here as args? */
print(info);
}
userInfo(Map user){
/* here you can use the map values like if you want to print the value of key
first_name */
print(user["first_name"]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.