updateFromYaml static method
void
updateFromYaml(
- dynamic yamlMap
Implementation
static void updateFromYaml(dynamic yamlMap) {
if (yamlMap == null) return;
// Handle theme configuration
if (yamlMap['theme'] != null) {
final theme = yamlMap['theme'];
// Parse container configuration
if (theme['container'] != null) {
final container = theme['container'];
containerCenter = container['center'] ?? true;
if (container['padding'] != null) {
final padding = container['padding'].toString();
containerPadding =
double.tryParse(padding.replaceAll('rem', '')) ?? 2.0 * 16;
}
if (container['screens'] != null) {
containerScreens = _parseScreens(container['screens']);
}
}
// Parse extend section
if (theme['extend'] != null) {
final extend = theme['extend'];
// Parse colors with HSL support
if (extend['colors'] != null) {
final userColors = _parseColorsWithHSL(extend['colors']);
colors = mergeColors(defaultTailwindColors, userColors);
}
// Parse border radius with CSS variable support
if (extend['borderRadius'] != null) {
final userRadius =
_parseBorderRadiusWithCSSVar(extend['borderRadius']);
borderRadius = {...borderRadius, ...userRadius};
}
// Parse font sizes with rem support
if (extend['fontSize'] != null) {
final userFontSize = _parseFontSizeWithRem(extend['fontSize']);
fontSize = mergeFontSize(defaultFontSize, userFontSize);
}
// Parse font weights
if (extend['fontWeight'] != null) {
final userFontWeight = _parseFontWeight(extend['fontWeight']);
fontWeight = mergeFontWeight(defaultFontWeight, userFontWeight);
}
// Parse spacing with rem support
if (extend['spacing'] != null) {
final userSpacing = _parseSpacingWithRem(extend['spacing']);
spacing = mergeSpacing(defaultSpacingScale, userSpacing);
}
// Parse box shadows with CSS variable support
if (extend['boxShadow'] != null) {
final userShadows = _parseBoxShadowsWithCSSVar(extend['boxShadow']);
boxShadow = {...boxShadow, ...userShadows};
}
// Parse line height
if (extend['lineHeight'] != null) {
lineHeight =
_parseLineHeight(extend['lineHeight']) as Map<String, double>;
}
// Parse letter spacing
if (extend['letterSpacing'] != null) {
letterSpacing = _parseLetterSpacing(extend['letterSpacing'])
as Map<String, double>;
}
// Parse opacity
if (extend['opacity'] != null) {
opacity = _parseOpacity(extend['opacity']) as Map<String, double>;
}
// Parse z-index
if (extend['zIndex'] != null) {
zIndex = _parseZIndex(extend['zIndex']) as Map<String, int>;
}
// Parse transition property
if (extend['transitionProperty'] != null) {
transitionProperty =
_parseTransitionProperty(extend['transitionProperty'])
as Map<String, List<String>>;
}
// Parse transition duration
if (extend['transitionDuration'] != null) {
transitionDuration =
_parseTransitionDuration(extend['transitionDuration'])
as Map<String, Duration>;
}
// Parse transition timing function
if (extend['transitionTimingFunction'] != null) {
transitionTimingFunction =
_parseTransitionTimingFunction(extend['transitionTimingFunction'])
as Map<String, Curve>;
}
}
}
if (yamlMap['colors'] != null) {
final userColors = _parseColors(yamlMap['colors']);
colors = mergeColors(defaultTailwindColors, userColors);
}
if (yamlMap['spacing'] != null) {
final userSpacing = _parseSpacing(yamlMap['spacing']);
spacing = mergeSpacing(defaultSpacingScale, userSpacing);
}
if (yamlMap['screens'] != null) {
final userScreens = _parseScreens(yamlMap['screens']);
screens = mergeScreens(defaultBreakpoints, userScreens);
}
if (yamlMap['fontSize'] != null) {
final userFontSize = _parseFontSize(yamlMap['fontSize']);
fontSize = mergeFontSize(defaultFontSize, userFontSize);
}
if (yamlMap['fontWeight'] != null) {
final userFontWeight = _parseFontWeight(yamlMap['fontWeight']);
fontWeight = mergeFontWeight(defaultFontWeight, userFontWeight);
}
if (yamlMap['borderWidth'] != null) {
final userBorderWidth = _parseBorderWidth(yamlMap['borderWidth']);
borderWidth = {...borderWidth, ...userBorderWidth};
}
screens = _parseScreens(yamlMap['screens']);
fontFamily = _parseFontFamily(yamlMap['fontFamily']);
borderRadius = _parseBorderRadius(yamlMap['borderRadius']);
boxShadow = _parseBoxShadows(yamlMap['boxShadow']); // Renamed method
// Parse filter configurations if provided
if (yamlMap['blur'] != null) {
blur = _parseBlur(yamlMap['blur']);
}
if (yamlMap['brightness'] != null) {
brightness = _parseBrightness(yamlMap['brightness']);
}
if (yamlMap['contrast'] != null) {
contrast = _parseContrast(yamlMap['contrast']);
}
if (yamlMap['dropShadow'] != null) {
dropShadow = _parseDropShadow(yamlMap['dropShadow']);
}
}