inlineCssToStyle function

Style? inlineCssToStyle(
  1. String? inlineStyle,
  2. OnCssParseError? errorHandler
)

Implementation

Style? inlineCssToStyle(String? inlineStyle, OnCssParseError? errorHandler) {
  var errors = <cssparser.Message>[];
  final sheet = cssparser.parse("*{$inlineStyle}", errors: errors);
  if (errors.isEmpty) {
    final declarations = DeclarationVisitor().getDeclarations(sheet);
    return declarationsToStyle(declarations["*"]!);
  } else if (errorHandler != null) {
    String? newCss = errorHandler.call(inlineStyle ?? "", errors);
    if (newCss != null) {
      return inlineCssToStyle(newCss, errorHandler);
    }
  }
  return null;
}