jsObjectToMap function

Map? jsObjectToMap(
  1. JsObject? o
)

Converts a JsObject o to a Map. Also converts keys and values using jsToDart.

Implementation

Map? jsObjectToMap(JsObject? o) {
  if (o == null) return null;

  var keys = jsObjectKeys(o);
  if (keys.isEmpty) return {};

  return Map.fromEntries(keys.map((k) {
    var v = o[k];
    return MapEntry(k, jsToDart(v));
  }));
}