addTypeAutowrapper method

void addTypeAutowrapper(
  1. TypeAutowrapper wrapper
)

Add a type autowrapper to the runtime. Type autowrappers are used to automatically wrap values of a certain type into a $Value. They should be used sparingly due to their high performance overhead.

Type autowrappers should implement the code pattern:

$Value? myTypeAutowrapper(dynamic value) {
  if (value is MyType) {
    return $MyType.wrap(value);
  } else if (value is MyOtherType) {
    return $MyOtherType.wrap(value);
  }
  return null;
}

Implementation

void addTypeAutowrapper(TypeAutowrapper wrapper) {
  _typeAutowrappers.add(wrapper);
}