mix<Owner extends Object, Value extends Object, PropValue extends Object> static method
MixProtocolFieldCodec<Owner, Prop<PropValue> >
mix<Owner extends Object, Value extends Object, PropValue extends Object>({
- required String wire,
- required MixProtocolValueCodec<
Value> codec, - required Prop<
PropValue> ? read(- Owner value
- String? fieldName,
- String? inventoryName,
Creates a property field whose sources are Mix values.
Implementation
static MixProtocolFieldCodec<Owner, Prop<PropValue>>
mix<Owner extends Object, Value extends Object, PropValue extends Object>({
required String wire,
required MixProtocolValueCodec<Value> codec,
required Prop<PropValue>? Function(Owner value) read,
String? fieldName,
String? inventoryName,
}) {
final fieldNameOrWire = fieldName ?? wire;
final customCodec = codec._mixPropCodec?.call(fieldNameOrWire);
if (customCodec != null) {
return MixProtocolFieldCodec._(
SchemaField<Owner, Prop<PropValue>>(
wire: wire,
codec: customCodec as AckSchema<Object, Prop<PropValue>>,
inventoryName: inventoryName,
schemaSemantics: codec._fieldSemantics,
read: read,
),
);
}
return MixProtocolFieldCodec._(
propMixField<Owner, Value, PropValue>(
wire,
codec._schema,
read,
fieldName: fieldName,
inventoryName: inventoryName,
schemaSemantics: codec._fieldSemantics,
convertValue: (value) => codec._convertValue?.call(value),
),
);
}