encode method
Encode object to bytes.
Example:
final person = Person(name: "john");
final bytes = messageAdapter.encode(person);
Implementation
@override
Uint8List encode(Object object, String topic, dynamic encoder) {
final json = jsonEncode(object);
final List<int> codeUnits = json.codeUnits;
final Uint8List bytes = Uint8List.fromList(codeUnits);
return bytes;
}