getMarginForAlignment function

EdgeInsets getMarginForAlignment({
  1. required double top,
  2. required double bottom,
  3. required double left,
  4. required double right,
  5. required String horizontalAlignment,
  6. required String verticalAlignment,
  7. double scaleWidth = 1.0,
  8. double scaleHeight = 1.0,
  9. required String id,
})

Implementation

EdgeInsets getMarginForAlignment({
  required double top,
  required double bottom,
  required double left,
  required double right,
  required String horizontalAlignment,
  required String verticalAlignment,
  double scaleWidth = 1.0,
  double scaleHeight = 1.0,
  required String id,
}) {
  EdgeInsets getMargin(String horAl, String verAl) {
    if (id.contains("container")) {
      return EdgeInsets.only(
        top: top * scaleHeight,
        bottom: bottom * scaleHeight,
        left: left * scaleWidth,
        right: right * scaleWidth,
      );
    }

    switch (verAl) {
      case 'top':
        switch (horAl) {
          case 'left':
            return EdgeInsets.only(
              top: top * scaleHeight,
              left: left * scaleWidth,
            );
          case 'right':
            return EdgeInsets.only(
              top: top * scaleHeight,
              right: right * scaleWidth,
            );
          default:
            return EdgeInsets.only(
              top: top * scaleHeight,
              left: left * scaleWidth,
              // right: right * scaleWidth,
            );
        }
      case 'bottom':
        switch (horAl) {
          case 'left':
            return EdgeInsets.only(
              bottom: bottom * scaleHeight,
              left: left * scaleWidth,
            );
          case 'right':
            return EdgeInsets.only(
              bottom: bottom * scaleHeight,
              right: right * scaleWidth,
            );
          default:
            return EdgeInsets.only(
              bottom: bottom * scaleHeight,
              left: left * scaleWidth,
              // right: right * scaleWidth,
            );
        }
      default:
        switch (horAl) {
          case 'left':
            return EdgeInsets.only(
              top: top * scaleHeight,
              // bottom: bottom * scaleHeight,
              left: left * scaleWidth,
            );
          case 'right':
            return EdgeInsets.only(
              top: top * scaleHeight,
              // bottom: bottom * scaleHeight,
              right: right * scaleWidth,
            );
          default:
            return EdgeInsets.only(
              top: top * scaleHeight,
              bottom: bottom * scaleHeight,
              left: left * scaleWidth,
              right: right * scaleWidth,
            );
        }
    }
  }

  return getMargin(horizontalAlignment, verticalAlignment);
}