length property

int get length

Number of bytes in the selection.

Returns the count of selected bytes. For inclusive range 0, 9, returns 10. Guaranteed to be non-negative.

Example:

ByteSelection(startOffset: 5, endOffset: 9).length; // 5 bytes
ByteSelection.single(10).length; // 1 byte

Implementation

int get length =>
    (endOffset - startOffset + 1).clamp(0, double.infinity).toInt();