serializeOptional function

void serializeOptional(
  1. Type self,
  2. SerialBuffer buffer,
  3. Object? data, {
  4. SerializerState? state,
  5. bool? allowExtensions = true,
})

Implementation

void serializeOptional(Type self, SerialBuffer buffer, Object? data, {SerializerState? state, bool? allowExtensions = true}) {
  state ??= SerializerState();
  if (data == null) {
    buffer.push([0]);
  } else {
    buffer.push([1]);
    self.optionalOf!.serialize!(self.optionalOf, buffer, data, state: state, allowExtensions: allowExtensions);
  }
}