write abstract method
Encodes value (possibly null) at byteOffset. Must write exactly
encodedSize bytes (out is zeroed when freshly allocated, but a codec
must not rely on that for the hasValue flag).
Implementation
void write(ByteData out, int byteOffset, T? value);