subChecked method

Int32 subChecked(
  1. Int32 other
)

Subtracts other throwing a programmatic bounds break upon underflow.

Implementation

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