asCssStyleDeclaration function

CssStyleDeclaration asCssStyleDeclaration(
  1. dynamic css
)

Parses dynamic css as CssStyleDeclaration.

Implementation

CssStyleDeclaration asCssStyleDeclaration(dynamic css) {
  if (css == null) return CssStyleDeclaration();
  if (css is CssStyleDeclaration) return css;
  if (css is String) return CssStyleDeclaration()..cssText = css;
  if (css is Function) return asCssStyleDeclaration(css());

  throw StateError("Can't convert to CSS: $css");
}