BoxBaseStyles constructor

BoxBaseStyles({
  1. required StyleSheet styleSheet,
  2. required Breakpoints activeBreakpoint,
})

Implementation

BoxBaseStyles({
  required this.styleSheet,
  required this.activeBreakpoint,
}) {
  // [width]
  var baseWidth =
      resolveValueForBreakpoint(styleSheet.width, activeBreakpoint);
  if (baseWidth != null) {
    width = double.parse(baseWidth);
  }
  // [height]
  var baseHeight =
      resolveValueForBreakpoint(styleSheet.height, activeBreakpoint);
  if (baseHeight != null) {
    height = double.parse(baseHeight);
  }

  // [color]
  color = colorResolver(
      resolveValueForBreakpoint(styleSheet.color, activeBreakpoint) ?? color);

  // [backgroundColor]
  backgroundColor = colorResolver(resolveValueForBreakpoint(
          styleSheet.backgroundColor, activeBreakpoint) ??
      backgroundColor);

  // [margin]
  margin = doubleValueResolver(styleSheet.margin, margin, activeBreakpoint);
  marginVertical = doubleValueResolver(
      styleSheet.marginVertical, marginVertical, activeBreakpoint);
  marginHorizontal = doubleValueResolver(
      styleSheet.marginHorizontal, marginHorizontal, activeBreakpoint);
  marginTop = doubleValueResolver(
        styleSheet.marginTop,
        marginTop,
        activeBreakpoint,
      ) ??
      marginVertical ??
      margin;
  marginBottom = doubleValueResolver(
        styleSheet.marginBottom,
        marginBottom,
        activeBreakpoint,
      ) ??
      marginVertical ??
      margin;
  marginLeft = doubleValueResolver(
        styleSheet.marginLeft,
        marginLeft,
        activeBreakpoint,
      ) ??
      marginHorizontal ??
      margin;
  marginRight = doubleValueResolver(
        styleSheet.marginRight,
        marginRight,
        activeBreakpoint,
      ) ??
      marginHorizontal ??
      margin;

  // [padding]
  padding =
      doubleValueResolver(styleSheet.padding, padding, activeBreakpoint);
  paddingVertical = doubleValueResolver(
      styleSheet.paddingVertical, paddingVertical, activeBreakpoint);
  paddingHorizontal = doubleValueResolver(
      styleSheet.paddingHorizontal, paddingHorizontal, activeBreakpoint);

  paddingTop = doubleValueResolver(
        styleSheet.paddingTop,
        paddingTop,
        activeBreakpoint,
      ) ??
      paddingVertical ??
      padding;
  paddingBottom = doubleValueResolver(
        styleSheet.paddingBottom,
        paddingBottom,
        activeBreakpoint,
      ) ??
      paddingVertical ??
      padding as double;
  paddingLeft = doubleValueResolver(
        styleSheet.paddingLeft,
        paddingLeft,
        activeBreakpoint,
      ) ??
      paddingHorizontal ??
      padding;
  paddingRight = doubleValueResolver(
        styleSheet.paddingRight,
        paddingRight,
        activeBreakpoint,
      ) ??
      paddingHorizontal ??
      padding;

  // [flexDirection]
  flexDirection =
      resolveValueForBreakpoint(styleSheet.flexDirection, activeBreakpoint) ??
          flexDirection;

  // [mainAxisAlignment|justifyContent]
  var justifyContent =
      resolveValueForBreakpoint(styleSheet.justifyContent, activeBreakpoint);
  mainAxisAlignment = resolveValueForBreakpoint(
          styleSheet.mainAxisAlignment, activeBreakpoint) ??
      justifyContent ??
      mainAxisAlignment;

  // [crossAxisAlignment|alignItems]
  var alignItems =
      resolveValueForBreakpoint(styleSheet.alignItems, activeBreakpoint);
  crossAxisAlignment = resolveValueForBreakpoint(
          styleSheet.crossAxisAlignment, activeBreakpoint) ??
      alignItems ??
      crossAxisAlignment;

  // [flex]
  flex = resolveValueForBreakpoint(styleSheet.flex, activeBreakpoint);

  // [overflowY]
  overflowY =
      resolveValueForBreakpoint(styleSheet.overflowY, activeBreakpoint);

  // [borderRadius]
  var borderRadiusValue =
      resolveValueForBreakpoint(styleSheet.borderRadius, activeBreakpoint);
  borderRadius =
      (borderRadiusValue != null) ? double.parse(borderRadiusValue) : 0;

  var borderRadiusTopLeftValue = resolveValueForBreakpoint(
      styleSheet.borderRadiusTopLeft, activeBreakpoint);
  borderRadiusTopLeft = (borderRadiusTopLeftValue != null)
      ? double.parse(borderRadiusTopLeftValue)
      : borderRadius;

  var borderRadiusTopRightValue = resolveValueForBreakpoint(
      styleSheet.borderRadiusTopRight, activeBreakpoint);
  borderRadiusTopRight = (borderRadiusTopRightValue != null)
      ? double.parse(borderRadiusTopRightValue)
      : borderRadius;

  var borderRadiusBottomLeftValue = resolveValueForBreakpoint(
      styleSheet.borderRadiusBottomLeft, activeBreakpoint);
  borderRadiusBottomLeft = (borderRadiusBottomLeftValue != null)
      ? double.parse(borderRadiusBottomLeftValue)
      : borderRadius;

  var borderRadiusBottomRightValue = resolveValueForBreakpoint(
      styleSheet.borderRadiusBottomRight, activeBreakpoint);
  borderRadiusBottomRight = (borderRadiusBottomRightValue != null)
      ? double.parse(borderRadiusBottomRightValue)
      : borderRadius;

  // [boxShadow]
  boxShadowOffsetX = doubleValueResolver(
    styleSheet.boxShadowOffsetX,
    boxShadowOffsetX,
    activeBreakpoint,
  ) as double;
  boxShadowOffsetY = doubleValueResolver(
    styleSheet.boxShadowOffsetY,
    boxShadowOffsetY,
    activeBreakpoint,
  ) as double;
  boxShadowBlur = doubleValueResolver(
    styleSheet.boxShadowBlur,
    boxShadowBlur,
    activeBreakpoint,
  ) as double;
  boxShadowSpread = doubleValueResolver(
    styleSheet.boxShadowSpread,
    boxShadowSpread,
    activeBreakpoint,
  ) as double;
  boxShadowColor = colorResolver(resolveValueForBreakpoint(
          styleSheet.boxShadowColor, activeBreakpoint) ??
      boxShadowColor);

  // [position]
  position =
      resolveValueForBreakpoint(styleSheet.position, activeBreakpoint) ??
          position;

  top = doubleValueResolver(styleSheet.top, top, activeBreakpoint);
  right = doubleValueResolver(styleSheet.right, right, activeBreakpoint);
  bottom = doubleValueResolver(styleSheet.bottom, bottom, activeBreakpoint);
  left = doubleValueResolver(styleSheet.left, left, activeBreakpoint);
}