serialize<T> function
Serializes a Dart object by getting its encoder from CodableMap
You will need to initiate your custom interface first in order to serialize using this method.
Implementation
Map<String, dynamic> serialize<T>(T object) {
final encoder = CodableMap.getEncoder<T>();
return encoder(object);
}