Description
Using IntelliJ CE for a web app I have the following concern. debugging with Dart 2.16
I decode an object with json and then cast it to a List<List<String>> meta
Later, I try
for (List<String> list in meta) {...
This compiles but produces a runtime error of
List<dynamic>
is not a List<String>
The type in the debugger is cast._new (I think) and the item
looks like a List<String>
.
It seems to me that this is not a great behavior. I think the runtime
ought to know that this is ok, but that further runtime checks will
need to be done when the list in the for loop is read.
If this is not going to be allowed at runtime, then I think the type of meta should be
a compile time syntax error.
Some way of specifying List<List<cast.String>>
might be an alternative, although List<List<dynamic>>
is ok.
If needed, I can produce and test a simple example to duplicate the behavior.