I come from as3 environment, so I am big beginner in dart and HTML.
I have this variable
var symbols = [
{"name":"first",
"num":[2,2,3]
}];
I want to access num array and save it to variable, I try to do this:
var symbol = symbols[0];
var num = symbol.num;
I get
Breaking on exception: Class '_LinkedHashMap' has no instance getter 'num'.
Can you help me please?
What you have is a list of a map of String to String. You could write the type like this:
List<Map<String, String>> symbols;
so naturally what you want to access is the value for the key "num". You can do this:
symbols[0]['num']
but it doesn't automatically gets mapped to an instance variable by writing:
symbol.num
If you had a class like this, the above would work:
class Symbol {
var num;
}
It doesn't work this way in Dart.
Try:
symbols[0]['num']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With