flutter - 如何在飞镖中调用采用 Map 类型参数的函数?
问题描述
我想知道 Map 的执行情况。
void main(){
var info = userInfo(); /* what can I pass here as args? */
print(info);
}
userInfo(Map user){
/* what do I write here? */
}
解决方案
您好,您可以通过地图并使用地图如下
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"]);
}
推荐阅读
- c# - 表集的 UpdateAll 失败
- python - 使用 L2 正则化优化稀疏 softmax 交叉熵
- java - Spring JPA 问题 AWS Ec2 和 RDS
- javascript - javascript cookie 的过期日期不起作用 - 已更新
- jenkins - 从 Eclipse 触发 jenkins 工作
- macos - OS X pip3 被 brew install python3.6.5_1 破坏
- react-native - 如何在 iOS 上从源代码使用 React Native?
- sql-server - SQL Server:在远程服务器上运行存储过程以删除数据
- android - 切换活动冻结动画
- vim - 我如何获得不同版本的 vim 以忽略 ~/vimrc 中它们不是插件的部分?