decode<T> method
Decode bytes to generic typed object.
You need to pass constructor tearoffs
for your type in decoder
parameter.
https://github.com/dart-lang/language/blob/main/accepted/2.15/constructor-tearoffs/feature-specification.md
Example of using fromJson that accepts Map to constuct Person
instance:
Person personFromBytes = jsonMessageAdapter.decode(bytes, Person.fromJson);
Implementation
@override
T decode<T>(Uint8List bytes, dynamic decoder) {
final json = jsonDecode(String.fromCharCodes(bytes));
T item = decoder(json);
return item;
}