encode method

  1. @override
Uint8List encode(
  1. Object object,
  2. String topic,
  3. dynamic encoder
)
override

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) {
  List<int> bytes = utf8.encode(object as String);
  return Uint8List.fromList(bytes);
}