I am trying to index/extract specific elements from specific lists in a map, however, I keep getting an error on android studio that says:
"The method '[]' can't be unconditionally invoked because the receiver can be 'null'."
In this simple example I'm trying to print the letter "B" by indexing twice using two sets of []. Android studio suggests I put a ! in between the two square brackets ( i.e ["x"]![1] ), however, I don't know what that does, nor does it fix the problem. It is really frustrating because I tried this code out on replit.com and it works exactly as I intended it, however once I try it in android studio or a flutter app it doesn't work...
An explanation as to why it doesn't work and a work around would be greatly appreciated.
import "dart:core";
void main() {
var test = {
"x": ["A", "B", "C"],
"z": ["D", "E", "F"],
};
print(test["x"][1]);
}