ImageSliderStyle constructor

ImageSliderStyle(
  1. ImageSliderStyleEnum style,
  2. double imgWidth
)

Factory constructor that creates a style based on the preset and image width

Returns a ImageSliderStyle instance with dimensions calculated according to the provided style preset and imgWidth parameter.

If an unknown style is provided, defaults to ImageSliderStyleEnum.DEFAULT.

Implementation

factory ImageSliderStyle(ImageSliderStyleEnum style, double imgWidth) {
  assert(imgWidth > 0, 'Image width must be positive');

  switch (style) {
    case ImageSliderStyleEnum.DEFAULT:
      return ImageSliderStyle._(
        imageWidth: imgWidth,
        borderWidth: _StyleConstants.defaultBorderWidth,
        strokeWidth: imgWidth,
        anchorWidth: imgWidth / 2,
      );

    case ImageSliderStyleEnum.NODE_BORDERLESS:
      return ImageSliderStyle._(
        imageWidth: imgWidth,
        borderWidth: _StyleConstants.noBorderWidth,
        strokeWidth: imgWidth * _StyleConstants.nodeStrokeRatio,
        anchorWidth: imgWidth / 2,
      );

    case ImageSliderStyleEnum.BORDERLESS:
      return ImageSliderStyle._(
        imageWidth: imgWidth,
        borderWidth: _StyleConstants.noBorderWidth,
        strokeWidth: imgWidth,
        anchorWidth: imgWidth / 2,
      );

    case ImageSliderStyleEnum.NODE:
      return ImageSliderStyle._(
        imageWidth: imgWidth,
        borderWidth: _StyleConstants.defaultBorderWidth,
        strokeWidth: imgWidth * _StyleConstants.nodeStrokeRatio,
        anchorWidth: imgWidth / 2,
      );

    case ImageSliderStyleEnum.LINE:
      return ImageSliderStyle._(
        imageWidth: imgWidth,
        borderWidth: _StyleConstants.defaultBorderWidth,
        strokeWidth: _StyleConstants.lineStrokeWidth,
        anchorWidth: _StyleConstants.lineStrokeWidth,
      );

    case ImageSliderStyleEnum.LINE_BORDERLESS:
      return ImageSliderStyle._(
        imageWidth: imgWidth,
        borderWidth: _StyleConstants.noBorderWidth,
        strokeWidth: _StyleConstants.lineStrokeWidth,
        anchorWidth: _StyleConstants.lineStrokeWidth,
      );
  }
}