apply method
Apply all style utilities to a widget in the correct order
Implementation
Widget apply(BuildContext context, Widget child) {
Widget result = child;
// Apply utilities in the correct order (inner to outer)
// For text widgets, we need to apply color first to preserve text styling
if (child is Text && color != null) {
result = _applyTextColorDirect(context, child);
}
// 1. Padding (applied to the content)
if (hasPadding) {
result = TwPaddingUtils.apply(context, this, result);
}
// 2. Background Color (for non-text widgets or containers)
if (color != null && child is! Text) {
result = _applyBackgroundColor(context, result);
}
// 3. Border Radius (applied to the background container)
if (hasBorderRadius) {
result = TwRoundedUtils.apply(context, this, result);
}
// 4. Margin (outermost - wraps the background)
if (hasMargin) {
result = TwMarginUtils.apply(context, this, result);
}
// Future utilities would go here:
// 5. Border (wraps margin)
// 6. Shadow (wraps border)
return result;
}