length property Null safety

int length
override

The number of objects in this list.

The valid indices for a list are 0 through length - 1.

final numbers = <int>[1, 2, 3];
print(numbers.length); // 3

Implementation

@override
int get length => _wrappedList.length;
void length=(int newLength)
override

Unsupported -- violated non-null constraint imposed by protobufs.

Changes the length of the list. If newLength is greater than the current length, entries are initialized to null. Throws an UnsupportedError if the list is not extendable.

Implementation

@override
set length(int newLength) {
  if (newLength > length) {
    throw UnsupportedError('Extending protobuf lists is not supported');
  }
  _wrappedList.length = newLength;
}