elementCss static method
Build CSS for an html element.
selector
is the element selector, like body
or h1
. You can chain selectors
like body h1
or body, h1
, etc.
properties
is a map of CSS properties and values, like color: #000000;
.
Example of string built:
CssBuilder.elementCss(
selector: '.note-editable',
properties: {
'color': '#000000',
'background-color': '#ffffff',
}
);
Result:
.note-editable {
color: #000000;
background-color: #ffffff;
}
Implementation
static String elementCss({required String selector, required Map<String, String> properties}) {
var css = '$selector{';
for (final entry in properties.entries) {
css += '${entry.key}:${entry.value};';
}
css += '}';
return css;
}