websocketBody property
ClientParam?
get
websocketBody
Implementation
ClientParam? get websocketBody {
if (!websocketType.canSendAny) {
return null;
}
final body = parameters.separate.body;
if (body.isEmpty) {
return null;
}
if (body case [final part] when part.access.isEmpty) {
return switch (part.type) {
ClientType(isStream: true) => part,
ClientType(isFuture: true, typeArguments: [final type]) ||
final type => part.changeType(
ClientType(
name: 'Stream<${type.name}>',
isStream: true,
typeArguments: [type],
method: this,
),
),
};
}
final params = StringBuffer();
for (final param in body) {
params.write('${param.type.name} ${param.name}, ');
}
return ClientParam(
name: 'body',
position: ParameterPosition.body,
access: [],
acceptMultiple: false,
hasDefaultValue: false,
type: ClientType(
name: 'Stream<({$params})>',
isStream: true,
recordProps: [],
method: this,
typeArguments: [
ClientType(
name: '({$params})',
typeArguments: [],
isRecord: true,
recordProps: [
for (final param in body)
ClientRecordProp(
name: param.name,
isNamed: true,
type: param.type..method = this,
),
],
),
],
),
);
}