我有一个二维列表,如indexList = [[1,A],[2,B],[3,C] ...]。我需要检查此2d列表是否包含另一个列表,例如item = [2,B]。我试过包含,listEquals,indexWhere,但它们都不起作用。在下面,是我的代码的一些示例。我该如何解决?
索引,此处为示例
AppButton.buildAppButton(
context,
AppButtonType.BETSELECTION,
matchList[index][6],
kCategoryButtonDimensions,
color: tappedRowButtonIndex.indexWhere((test) =>
test.contains([
tappedRowIndex,
tappedButtonIndex
])) !=
null
? Colors.yellow
: Colors.white,
列表等于示例
AppButton.buildAppButton(
context,
AppButtonType.BETSELECTION,
matchList[index][6],
kCategoryButtonDimensions,
color: listEquals(tappedRowButtonIndex, [tappedRowIndex, tappedRowButtonIndex])
? Colors.yellow
: Colors.white,
onPressed: () {
tappedRowIndex = index;
tappedButtonIndex = 3;
包含示例
AppButton.buildAppButton(
context,
AppButtonType.BETSELECTION,
matchList[index][5],
kCategoryButtonDimensions,
color: tappedRowButtonIndex.contains(
[tappedRowIndex, tappedButtonIndex])
? Colors.yellow
: Colors.white,
onPressed: () {
tappedRowIndex = index;
tappedButtonIndex = 2;