addChecked method

Uint16 addChecked(
  1. Uint16 other
)

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

Implementation

Uint16 addChecked(Uint16 other) {
  final result = value + other.value;
  if (result > 65535 || result < 0) throw StateError('Uint16 addition overflow');
  return Uint16.from(result);
}