Piece constructor

Piece({
  1. dynamic shape,
  2. double? width,
  3. double? height,
  4. String? char,
  5. TextStyle? charStyle,
  6. Color? backgroundColor,
  7. double? clipHeight,
  8. int? index,
  9. Radius? borderRadius,
})

Implementation

Piece(
    {this.shape,
    this.width,
    this.height,
    this.char,
    this.charStyle,
    this.backgroundColor,
    this.clipHeight,
    this.index, this.borderRadius,
    }) {
  final Widget shapeContainer = Container(
    decoration: BoxDecoration(
      color: this.backgroundColor,
    ),
    alignment: Alignment.center,
    width: this.width,
    height: this.height,
    child: Text(
      this.char!,
      style: this.charStyle,
    ),
  );

  if (this.shape.runtimeType == DIAGONAL) {
    this.renderWidget = ClipRRect(
      borderRadius: BorderRadius.only(
          topLeft: this.shape == DIAGONAL.TOP_RIGHT || this.shape == DIAGONAL.BOTTOM_RIGHT ? this.borderRadius ?? Radius.circular(0) : Radius.circular(0),
          bottomLeft: this.shape == DIAGONAL.TOP_RIGHT || this.shape == DIAGONAL.BOTTOM_RIGHT ? this.borderRadius ?? Radius.circular(0) : Radius.circular(0),
          bottomRight: this.shape == DIAGONAL.TOP_LEFT || this.shape == DIAGONAL.BOTTOM_LEFT ? this.borderRadius ?? Radius.circular(0):Radius.circular(0),
          topRight: this.shape == DIAGONAL.TOP_LEFT || this.shape == DIAGONAL.BOTTOM_LEFT ? this.borderRadius ?? Radius.circular(0):Radius.circular(0)),
      child: Diagonal(
        axis: Axis.vertical,
        clipHeight: this.clipHeight!,
        position: (this.shape as DIAGONAL).EDGE!,
        child: shapeContainer,
      ),
    );
  } else {
    SHAPE_WIDGET _shapeBody = (this.shape as SHAPE_BODY).WIDGET!;
    if (_shapeBody == SHAPE_WIDGET.PARALLEL) {
      this.renderWidget = Parallelogram(
        cutLength: this.clipHeight!,
        edge: (this.shape as SHAPE_BODY).EDGE!,
        child: shapeContainer,
      );
    }
    if (_shapeBody == SHAPE_WIDGET.TRIPAZOID) {
      this.renderWidget = Trapezoid(
        cutLength: this.clipHeight!,
        edge: (this.shape as SHAPE_BODY).EDGE!,
        child: shapeContainer,
      );
    }
  }
}