subChecked method

Uint8 subChecked(
  1. Uint8 other
)

Subtracts other throwing a programmatic bounds break upon underflow.

Implementation

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