subChecked method

Uint16 subChecked(
  1. Uint16 other
)

Subtracts other throwing a programmatic bounds break upon underflow.

Implementation

Uint16 subChecked(Uint16 other) {
  final result = value - other.value;
  if (result > 65535 || result < 0) throw StateError('Uint16 subtraction overflow/underflow');
  return Uint16.from(result);
}