Dart - List first element cannot be null?

Viewed 23

In VSCode, if I write

class foo {
    List<MyObj> some_objs = [];

    MyObj get firstObject { return some_objs[0] ?? MyObj() };    // Left operand can't be null?
}

Intellisense tells me the left side of this expression can't be null. Is this an Intellisense error? The list exists but nothing is added to it. New at Dart here, thanks for any help.

1 Answers

Ah, now I see. The existence of the first element isn't the same as whether it contains null.

Related