CustomStylesBuilder typedef Null safety

CustomStylesBuilder = Map<String, String>? Function(Element element)

A callback to specify custom styling.

The returned Map will be applied as inline styles. See list of all supported inline stylings in README.md, the sample callback below changes the color for all elements that have CSS class name:

HtmlWidget(
  'Hello <span class="name">World</span>!',
  customStylesBuilder: (element) =>
    element.classes.contains('name') ? {'color': 'red'} : null,
)

Implementation

typedef CustomStylesBuilder = Map<String, String>? Function(
  dom.Element element,
);