resolveBackgroundImage static method
dynamic
resolveBackgroundImage(
- String present,
- RenderStyle renderStyle,
- String property,
- WebFController controller,
- String? baseHref,
Implementation
static resolveBackgroundImage(
String present, RenderStyle renderStyle, String property, WebFController controller, String? baseHref) {
// Expand CSS variables inside the background-image string so that
// values like linear-gradient(..., var(--tw-gradient-stops)) work.
// Tailwind sets --tw-gradient-stops to a comma-separated list
// (e.g., "var(--tw-gradient-from), var(--tw-gradient-to)") which
// must be expanded before parsing function args, otherwise only the
// first token would be seen and gradients would be dropped.
String expanded = _expandBackgroundVars(present, renderStyle);
List<CSSFunctionalNotation> functions = CSSFunction.parseFunction(expanded);
if (DebugFlags.enableBackgroundLogs) {
for (final f in functions) {
if (f.name == 'url') {
final raw = f.args.isNotEmpty ? f.args[0] : '';
renderingLogger.finer('[Background] resolve image url raw=$raw baseHref=${baseHref ?? controller.url}');
} else if (f.name.contains('gradient')) {
renderingLogger.finer('[Background] resolve gradient ${f.name} args=${f.args.length}');
}
}
}
return CSSBackgroundImage(functions, renderStyle, controller, baseHref: baseHref);
}