get String from nested Map in dart

别来无恙 提交于 2021-01-28 04:10:21

问题


My Map:

{Info: {name: Austin, Username: austinr}}

I'm using this line to get the myName variable to be set as "Austin"

String myName = map["name"] as String;

However.. this line seems to set the string "myName" to null. just looking for a way to extract my name and Username from the map

Thanks


回答1:


I am able to run the following code successfully.

 var map =  {"Info":{"name": "Austin", "Username": "austinr"}}; 
 String myString = map["Info"]["name"] as String;
 print(myString);

The output is Austin as expected. Please try this.



来源:https://stackoverflow.com/questions/52441043/get-string-from-nested-map-in-dart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!