writeEnum<E extends Enum> method

int writeEnum<E extends Enum>(
  1. E e
)

Writes an enum e index. Increments position by 1.

  • It won't allow enums with more than 255 values.

Implementation

int writeEnum<E extends Enum>(E e) {
  var index = e.index;
  if (index > 255) {
    throw StateError("Can't write an enum of index > 255: $index");
  }
  writeByte(index);
  return 1;
}