flutter - 错误:“列表”类型的值' 不能分配给 'List 类型的变量'
问题描述
我有 list temp 并调用函数 List 但发生此错误
此错误仅在更新颤振后发生
A value of type 'List<dynamic>' can't be assigned to a variable of type 'List<int>'.
我想虽然没有 List ,,,
我怎样才能解决这个问题 ??
List<int> arr = [];
List<List<int>> temp = [
[3,4],
[3,5],
[4,3],
[4,4],
[5,2],
[5,5],
[2,3],
[2,4],
];
arr = chord3(0,temp[2]); // I call chord3 function here
List chord3(f,List<int> s){ // this is function and error occurs here
List<int> temp = [];
temp.add(f);
temp.add(1);
return temp;
}
解决方案
只需在int
此处添加:
List<int>chord3(f,List<int> s){ // this is function and error occurs here
List<int> temp = [];
temp.add(f);
temp.add(1);
return temp;
}
你也有这个选项,同样的结果:
arr = List<int>.from(chord3(0,temp[2]));
推荐阅读
- java - Android检测(Call Waiting)第二次来电状态
- python - 如何将单行中的整数读入python循环中的数组?
- postgresql - 无法通过 GCP 重启 postgres 服务?
- python - OpenAI 健身房 - 没有名为“_policies”的模块
- google-chrome-extension - setSinkId API 在 Chrome 扩展程序中不起作用
- reactjs - 如何在这个 ant design 登录表单中实现最少 5 个字符的验证?我找不到例子
- sas - 在sas中的数字前面添加撇号
- python - 我已经使用 append 删除了重复项,但并不完全是如何工作的
- java-8 - Weblogic 12.2.1.3 似乎忽略了 BindingContextFactory 设置
- optimization - 如何在 AMPL 的控制台中仅显示等于 1 的二进制变量