final graph = switch (widget.type) {
CollectionGraphType.watchCollection => manager.breakdown,
CollectionGraphType.wristTime => manager.wristTime,
};
childKeys = graph.value?
.map((e) => GlobalKey(debugLabel: e.label))
.toList() ??
[];
Gives me the linter error “Conditions must have a static type of ‘bool’ at the ?
after value
.
Try changing the condition”
value is of type ValueNotifier<List<GraphSegmentDto>?>
if I replace the ?
with !
it works.
maks
November 3, 2024, 11:44pm
2
Is it maybe because ValueNotifier is a generic, so it becomes nullable if its T is nullable (which it is in your case). Its not surprising that !
makes it work as doing that you are force casting it to be non null.
But why doesn’t the? Work then and why thinks the analyser that it’s part of a tertiary expression?
Are you trying to write graph.value ?. map( … ?
If so, I don’t think you can put a space between the ? and .
maks
November 3, 2024, 11:55pm
5
Oh right! I see what you mean now. Yes that is strange!
It’s not too strange. You can’t put whitespace inside an identifier or between the < and = of <=.
maks
November 4, 2024, 12:02am
7
Randal do you mean the newline after the graph.value?
?
Actually there is no newline the formatter put it like that. And it works if I replace the ? With a ! Which should have the same problem
If the formatter split a ?.
operator, the formatter has a bug. But it should work fine with ?.
as long as you make sure there’s no space in there.
1 Like
thanks, indeed it was the formatting. We are performing a pretty big refactoring and somehow the formatter doesn’t format some of the files.
1 Like
BTW, I believe ?.
is set up as a single token due to plans for a convenient dot syntax in the near future
dart-lang/language#3685
2 Likes