buildSize method

Widget? buildSize([
  1. Widget? child
])

Implementation

Widget? buildSize([Widget? child]) {
  if (!hasSize) {
    return child;
  }
  final width = this.width ?? size;
  final height = this.height ?? size;
  if (minHeight != null || minWidth != null) {
    return ConstrainedBox(
      constraints: BoxConstraints(
          maxWidth: width ?? double.infinity,
          minWidth: minWidth ?? 0,
          maxHeight: height ?? double.infinity,
          minHeight: minHeight ?? 0),
      child: child,
    );
  }

  List<AntdBoxLayoutMode> behaviorModes = layoutModes ?? [];

  if (behaviorModes.contains(AntdBoxLayoutMode.aspectRatio) &&
      width != null &&
      height != null) {
    return AspectRatio(
      aspectRatio: width / height,
      child: child,
    );
  }

  if ((height != null || width != null) && behaviorModes.isEmpty) {
    return SizedBox(
      height: height,
      width: width,
      child: child,
    );
  }
  if (behaviorModes.contains(AntdBoxLayoutMode.factorWidth) &&
      width != null) {
    child = FractionallySizedBox(
      widthFactor: width,
      child: child,
    );
  }
  if (behaviorModes.contains(AntdBoxLayoutMode.factorHeight) &&
      height != null) {
    child = FractionallySizedBox(
      heightFactor: height,
      child: child,
    );
  }

  if (behaviorModes.contains(AntdBoxLayoutMode.fixedHeight) &&
      height != null) {
    child = SizedBox(
      height: height,
      child: child,
    );
  }

  if (behaviorModes.contains(AntdBoxLayoutMode.fixedWidth) && width != null) {
    child = SizedBox(
      width: width,
      child: child,
    );
  }

  return child;
}