我遇到了完全相同的错误,多个Dropdowns都从同一个静态列表中获取数据,唯一的区别是在我的情况下,它是对象列表,而不是字符串列表。
因此,如果它是静态列表,则不可能为空,列表中没有重复的值,并且您已经确定
value不为空?那么剩下的唯一选择
item.value就是与
value
就我而言,因为它是一个对象列表,所以我必须覆盖对象类中的
operator ==和
hashpre方法。
bool operator ==(dynamic other) => other != null && other is TimeSelection && this.hour == other.hour; @override int get hashCode => super.hashCode;
就是这样。我不必初始化
_value1或
_value2


![错误:检测到零个或两个或两个以上具有相同值I / flutter(18363)的[DropdownMenuItem]:'package:flutter /src / material / d 错误:检测到零个或两个或两个以上具有相同值I / flutter(18363)的[DropdownMenuItem]:'package:flutter /src / material / d](http://www.mshxw.com/aiimages/31/430783.png)
