register static method

void register(
  1. TypedMessage constructor()
)

The custom typed message should be registered before use it.

You can register constructor of your custom typed message like this:

class YourCustomTypedMessage extends TypedMessage {
  @override
  int get type => 1;

  YourCustomTypedMessage() : super();
}

TypedMessage.register(() => YourCustomTypedMessage());

Important: TypedMessage.type of your custom typed message should be a positive number.

Implementation

static void register(
  TypedMessage Function() constructor,
) {
  var instance = constructor();
  if (instance.type < 1) {
    throw ArgumentError(
      'type should be a positive number',
    );
  }
  TypedMessage._classMap[instance.type] = constructor;
}