apply static method

Widget apply(
  1. BuildContext context,
  2. FlyStyle style,
  3. Widget child
)

Applies flex properties to a widget

Implementation

static Widget apply(BuildContext context, FlyStyle style, Widget child) {
  final flex = resolveFlex(context, style);
  final flexGrow = resolveFlexGrow(context, style);
  final flexShrink = resolveFlexShrink(context, style);
  final flexBasis = resolveFlexBasis(context, style);

  // If grow is specified, use Expanded
  if (flexGrow != null && flexGrow > 0) {
    return Expanded(flex: flexGrow, child: child);
  }

  // If flex is specified, use Flexible
  if (flex != null) {
    // Handle 'none' case - return child without flex wrapper
    if (style.flex == 'none') {
      return child;
    }

    final fit = resolveFlexFit(context, style);

    return Flexible(flex: flex, fit: fit, child: child);
  }

  // If only shrink or basis is specified, use Flexible with default flex
  if (flexShrink != null || flexBasis != null) {
    return Flexible(flex: flexShrink ?? 1, fit: FlexFit.loose, child: child);
  }

  // No flex properties, return child as-is
  return child;
}