encode<V> static method

V encode<V>(
  1. SourceOwner instance,
  2. Encoder<V> encoder
)

Implementation

static V encode<V>(
  SourceOwner instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.address != null) {
    Address.encode(
      instance.address!,
      container.nestedSingleValueContainer('address').encoder,
    );
  }
  if (instance.email != null) {
    container.encodeString(
      'email',
      instance.email!,
    );
  }
  if (instance.name != null) {
    container.encodeString(
      'name',
      instance.name!,
    );
  }
  if (instance.phone != null) {
    container.encodeString(
      'phone',
      instance.phone!,
    );
  }
  if (instance.verifiedAddress != null) {
    Address.encode(
      instance.verifiedAddress!,
      container.nestedSingleValueContainer('verified_address').encoder,
    );
  }
  if (instance.verifiedEmail != null) {
    container.encodeString(
      'verified_email',
      instance.verifiedEmail!,
    );
  }
  if (instance.verifiedName != null) {
    container.encodeString(
      'verified_name',
      instance.verifiedName!,
    );
  }
  if (instance.verifiedPhone != null) {
    container.encodeString(
      'verified_phone',
      instance.verifiedPhone!,
    );
  }
  return container.value;
}