addChecked method

Int32 addChecked(
  1. Int32 other
)

Adds other dynamically intercepting any numerical layout overflow triggering a Dart StateError.

Implementation

Int32 addChecked(Int32 other) {
  final result = value + other.value;
  if (result > 2147483647 || result < -2147483648) throw StateError('Int32 addition overflow');
  return Int32.from(result);
}