applyFlexToChildren static method
Apply flex properties to children if they have flex utilities
Implementation
static List<Widget> applyFlexToChildren(
BuildContext context,
List<Widget> children,
) {
return children.map((child) {
// Check if the child has flex properties by looking for FlyFlexUtilities mixin
if (child is StatelessWidget) {
// Try to access the style property through reflection or type checking
try {
// Check if it's a FlyText, FlyContainer, or FlyBox with flex properties
if (child.runtimeType.toString().contains('FlyText') ||
child.runtimeType.toString().contains('FlyContainer') ||
child.runtimeType.toString().contains('FlyBox')) {
// Use reflection to get the flyStyle property
final dynamic widget = child;
if (widget.flyStyle != null && widget.flyStyle is FlyStyle) {
final FlyStyle style = widget.flyStyle;
if (FlyFlexUtils.hasFlexProperties(style)) {
return FlyFlexUtils.apply(context, style, child);
}
}
}
} catch (e) {
// If reflection fails, just return the child as-is
}
}
return child;
}).toList();
}