Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart-静态类型化列表中的值_Dart_Dart Editor_Dartium - Fatal编程技术网

Dart-静态类型化列表中的值

Dart-静态类型化列表中的值,dart,dart-editor,dartium,Dart,Dart Editor,Dartium,为什么这不是Dart中的错误 List<String> listA = ['aa', 1, 'cc']; //not compile time error, not run time error?? listA=['aa',1',cc']//非编译时错误,非运行时错误?? 我正在使用Dart编辑器。编写列表a=['aa',1',cc']就像写列表a=['aa',1',cc']。['aa',1,'cc']的运行时类型是List,它与您使用的类型注释List兼容 如果您想定义字符串列

为什么这不是Dart中的错误

List<String> listA = ['aa', 1, 'cc']; //not compile time error, not run time error??
listA=['aa',1',cc']//非编译时错误,非运行时错误??
我正在使用Dart编辑器。

编写
列表a=['aa',1',cc']就像写
列表a=['aa',1',cc']
['aa',1,'cc']
运行时类型是
List
,它与您使用的类型注释
List
兼容

如果您想定义
字符串列表
以在编辑器中显示警告并在运行时显示错误,您应该选择:

listA=['aa','cc'];
//或
最终列表a=['aa','cc'];
为了更好地理解,以下是一些示例:

print((['aa',1,'cc']).runtimeType);//列表
打印((['aa','cc'])。运行时类型);//列表
打印((['aa','cc'])。运行时类型);//列表
打印((['aa','cc'])。运行时类型);//列表
列表l1=['aa',1',cc'];//好啊
列表l2=['aa','cc'];//好啊
列表l3=['aa','cc'];//好啊
列表l4=['aa','cc'];//编辑器中的警告+运行时错误
Thx<代码>列表A=['aa',1',cc']确实在编辑器和运行时错误中给了我警告。
dart2js
不会因为这样的错误而停止编译,这是真的吗?为什么这不是编译时错误?