tryToMap function

dynamic tryToMap(
  1. dynamic object
)

Tries to convert an object to a map by calling its toMap method if it exists.

Implementation

dynamic tryToMap(dynamic object) {
  try {
    return object?.toMap();
  } catch (_) {
    return null;
  }
}