serializeOptional function

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

Implementation

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