encode method Null safety

String encode()

Implementation

String encode() {
  return cmd + jsonEncode(payload) + '\n';
}