applyPositionToChildren static method

List<Widget> applyPositionToChildren(
  1. BuildContext context,
  2. List<Widget> children
)

Apply position properties to children if they have position utilities

Implementation

static List<Widget> applyPositionToChildren(
  BuildContext context,
  List<Widget> children,
) {
  return children.map((child) {
    // Check if the child has position properties by looking for FlyPositionUtilities 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 position 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 (FlyPositionUtils.hasPositionProperties(style)) {
              return FlyPositionUtils.apply(context, style, child);
            }
          }
        }
      } catch (e) {
        // If reflection fails, just return the child as-is
      }
    }
    return child;
  }).toList();
}