convertStyle

JSObject convertStyle(

  1. Map<String, dynamic> style
)

Convert style map to JSObject for React inline styles Numeric values get 'px' suffix for size-related properties

Implementation

JSObject convertStyle(Map<String, dynamic> style) {
  final obj = JSObject();
  for (final entry in style.entries) {
    final value = entry.value;
    final jsValue = (value is num && _needsPxSuffix(entry.key))
        ? '${value}px'.toJS
        : (value is String)
            ? value.toJS
            : (value is num)
                ? value.toJS
                : (value as Object).jsify();
    obj.setProperty(entry.key.toJS, jsValue);
  }
  return obj;
}