tryToJson function
dynamic
tryToJson(
- dynamic object
Tries to convert an object to a json map by calling its toJson method if it exists.
Implementation
dynamic tryToJson(dynamic object) {
try {
return object?.toJson();
} catch (_) {
return null;
}
}