makeContainingTable static method

Widget makeContainingTable(
  1. BuildContext context,
  2. List<Widget> widgets,
  3. PlatformMediumModel? image,
  4. PresentationRelativeImagePosition? relativeImagePosition,
  5. PresentationImageAlignment? imageAlignment,
  6. double? imageSize,
)

Implementation

static Widget makeContainingTable(
    BuildContext context,
    List<Widget> widgets,
    PlatformMediumModel? image,
    PresentationRelativeImagePosition? relativeImagePosition,
    PresentationImageAlignment? imageAlignment,
    double? imageSize) {
  if (image == null) {
    return _makeBox(widgets);
  }

  if ((relativeImagePosition == null) ||
      (relativeImagePosition == PresentationRelativeImagePosition.unknown)) {
    relativeImagePosition = PresentationRelativeImagePosition.above;
  }
  if ((imageAlignment == null) ||
      (imageAlignment == PresentationImageAlignment.unknown)) {
    imageAlignment = PresentationImageAlignment.left;
  }

  double? size;
  if (imageSize != null) {
    size = fullScreenWidth(context) * imageSize;
  }
  var widgetImage = Image.network(image.url!);

  if (relativeImagePosition == PresentationRelativeImagePosition.aside) {
    Widget column1;
    Widget column2;
    if (size != null) {
      column1 = Container(
        alignment: Alignment.topCenter,
        width: size, // set this
        child: widgetImage,
      );
      column2 = Container(
        alignment: Alignment.topCenter,
        width: fullScreenWidth(context) - size, // set this
        child: _makeBox(widgets),
      );
    } else {
      column1 = Column(children: [
        widgetImage,
      ]);
      column2 = Column(children: [_makeBox(widgets)]);
    }
    if (imageAlignment == PresentationImageAlignment.left) {
      return Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          verticalDirection: VerticalDirection.down,
          children: [column1, column2]);
    } else {
      return Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          verticalDirection: VerticalDirection.down,
          children: [column2, column1]);
    }
  }

  Widget alignedWidget = _toAlignment(imageAlignment, widgetImage);
  if (relativeImagePosition == PresentationRelativeImagePosition.below) {
    var widgets = <Widget>[];
    widgets.addAll(widgets);
    widgets.add(alignedWidget);
    return _makeBox(widgets);
  }
  if (relativeImagePosition == PresentationRelativeImagePosition.above) {
    var newList = <Widget>[];
    newList.add(alignedWidget);
    newList.addAll(widgets);
    return _makeBox(newList);
  }
  if (relativeImagePosition == PresentationRelativeImagePosition.behind) {
    return Stack(children: <Widget>[
      alignedWidget,
      _makeBox(widgets),
    ]);
  }
  if (relativeImagePosition == PresentationRelativeImagePosition.inFront) {
    return Stack(children: <Widget>[
      _makeBox(widgets),
      alignedWidget,
    ]);
  }

  // error, not expecting this. Anyhu... return the box, just the box, drop the image
  return _makeBox(widgets);
}