addChecked method

Uint8 addChecked(
  1. Uint8 other
)

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

Implementation

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