Как узнать, что 2D-список содержит другой список во флаттере - PullRequest
0 голосов
/ 06 апреля 2020

У меня есть двухмерный список, такой как indexList = [[1, A], [2, B], [3, C] ...]. Мне нужно проверить, что этот 2D-список содержит другой список, например item = [2, B] или нет. Я пробовал содержит, listEquals, indexWhere, но ни один из них не работает. Ниже приведены некоторые примеры моего кода. Как я могу решить эту проблему?

indexWhere пример

                         AppButton.buildAppButton(
                            context,
                            AppButtonType.BETSELECTION,
                            matchList[index][6],
                            kCategoryButtonDimensions,
                            color: tappedRowButtonIndex.indexWhere((test) =>
                                        test.contains([
                                          tappedRowIndex,
                                          tappedButtonIndex
                                        ])) !=
                                    null
                                ? Colors.yellow
                                : Colors.white,

listEquals пример

                    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;
...