When checking for null, we frequently use a ternary operator. But there is an operator that could make code a bit shorter.
void main() {
int getLength(List? list) => list?.length ?? 0; // list != null ? list.length : 0
print(getLength(null));
}
'??' operator will give the value on the left if the value isn't null. Otherwise, returns the value on the right.