I want the user input to compare with each list (normalList, protanList,deutanList, tritanList)
so, assuming if the the user input is 1 – 15 correctly, and the output will be "Normal"
if the user input is [15,14,1,2,13,12,3,4,11,10,5,6,9,8,7] ,the output will be "Protan"
Please help, this is my final year project and I’m totally blank about what to do
late List<Box> opaqueBoxes = []; //to be filled
//assume opaqueBoxes being input by user here
//the result method is to compare the outcome of the result
String result() {
String result = ”;
if (listEquals(normalList, opaqueBoxes)) {
result = "Normal";
} else {
result = "Protan";
}
if (kDebugMode) {
print(result);
}
return result;
}//here is the list of the correct one
var normalList = [
"1",
"2",
"3",
"4",
"5",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15"
];
var protanList = [
"15",
"14",
"1",
"2",
"13",
"12",
"3",
"4",
"11",
"10",
"5",
"6",
"9",
"8",
"7"
];var deutanList = [
"1",
"15",
"2",
"3",
"14",
"13",
"4",
"12",
"5",
"6",
"11",
"10",
"7",
"9",
"8"
];var tritanList = [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"15",
"8",
"14",
"9",
"13",
"10",
"11",
"12"
];
2
Answers
So I already documented what I wanted to say in the code below. But here is a quick one.
First, note that I don’t think
listEquals
is in support anymore. You will have to create your filter condition.This is easy and complex. There is no way to get a variable name without typing
them or writing a new class. Well, deep in and see what I did. I will try and make things easy and strong.
Also when posting a question with the codebase, always use the "Code Sample not the "Blockquote" on your textarea.
If you need further assistance let me know.
#TO PUT EVERYTHING SIMPLY
If you need both lists to maintain the same sequence, then try this way :
And if you don’t need to have the items in exact same sequence you can try this :
Now you can try and figure out your ways to create a result from it. And learn in the process. Good luck. 👍