styles property
List<Declaration>
styles
Returns CSS declarations from the element's style
attribute.
This is different from BuildTree.styles as it doesn't include runtime additions from WidgetFactory or BuildOps.
Parsing CSS is a non-trivial task but the result is cached so it's safe to call this again and again.
Implementation
List<css.Declaration> get styles {
final expando = _expando ??= Expando();
final existing = expando[this];
if (existing != null) {
return existing;
}
if (!attributes.containsKey('style')) {
return expando[this] = const [];
}
final styleSheet = css.parse('*{${attributes['style']}}');
return expando[this] = styleSheet.collectDeclarations();
}