call method
Encodes the provided data to platform specific format. The encoded data can be added to DataWriterItem.
final item = DataWriterItem();
item.add(Format.plainText('Hello World'));
Implementation
@override
FutureOr<EncodedData> call(T data) {
final encoder = codec;
final entries = <raw.DataRepresentationSimple>[];
bool needResolve = false;
for (final format in encoder.encodingFormats) {
final representation = raw.DataRepresentation.simple(
format: format, data: encoder.encode(data, format));
needResolve |= representation.data is Future;
entries.add(representation);
}
if (needResolve) {
return _resolveEntries(entries);
} else {
return EncodedData(entries);
}
}