I have a flutter app. I'm using VSCode. When I do the following I get the following error reported in two places (the 'PROBLEMS' area and in the 'Debug Console':
faulty code:
bool fff = (preferences?.getBool("_wantSpaces"));
error msg:
"message": "A value of type 'bool?' can't be assigned to a variable of type 'bool'.\nTry changing the type of the variable, or casting the right-hand type to 'bool'.",
If I modify the code like this both errors go away: good code:
bool fff = (preferences?.getBool("_wantSpaces")) ?? false;
But, if I modify the code like this only the error in the 'Problems' goes away: half good code:
bool fff = (preferences?.getBool("_wantSpaces"))!;
Questions: Why is the error reported in 2 places? I would prefer to use the 2nd form (with the !), but I can't
Thanks