Is there a type check on the list of cards in the dart?
For example, if you have a list:
List<Map<String,int>> list = <Map<String,int>>[ {"string1": 44}, {"string2" : "string in place of int"} ];
or
List<Map<String,int>> list = new List<Map<String,int>>(); list.addAll([ {"string1": 44}, {"string2" : "string in place of int"}] );
Shouldn't there be a warning for "string instead of int"?
+3
source to share
3 answers
In Dart, the static controller does not complain about all possible type violations, because there is a chance that the code is correct. At runtime, when an illegal operation is performed, you get an exception.
When I use:
{"string2" : "string in place of int"}
I am making a map:, Map<dynamic,dynamic>
dynamic disables static validation.
Dart lets you run this code because down assignments can be valid, and Dart is optimistic that you know what you are doing.
So my map might be Map<String,int>
, then it will be correct unless an exception is thrown.
0
source to share