问题
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