Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there no type checking in a list of maps in dart?

Tags:

dart

For example if you have the 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 in place of int" ?

like image 383
Raizul Avatar asked Dec 03 '25 16:12

Raizul


1 Answers

Types are not used by Dart unless you execute your code in checked mode.

When Dart is not in checked mode (which should be the case in production) having no types at all, wrong types or right types makes no difference (no error, no speed gain).

like image 60
vicb Avatar answered Dec 05 '25 10:12

vicb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!