BoxBaseStyles constructor

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

Implementation

BoxBaseStyles({
  required this.styleSheet,
  required this.activeBreakpoint,
}) {
  // [width]
  width = doubleValueResolver(
    styleSheet.width,
    width,
    activeBreakpoint,
  );
  // [height]
  height = doubleValueResolver(
    styleSheet.height,
    height,
    activeBreakpoint,
  );

  // [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]
  borderRadius = doubleValueResolver(
    styleSheet.borderRadius,
    borderRadius,
    activeBreakpoint,
  );

  borderRadiusTopLeft = doubleValueResolver(
        styleSheet.borderRadiusTopLeft,
        borderRadiusTopLeft,
        activeBreakpoint,
      ) ??
      borderRadius;

  borderRadiusTopRight = doubleValueResolver(
        styleSheet.borderRadiusTopRight,
        borderRadiusTopRight,
        activeBreakpoint,
      ) ??
      borderRadius;

  borderRadiusBottomLeft = doubleValueResolver(
        styleSheet.borderRadiusBottomLeft,
        borderRadiusBottomLeft,
        activeBreakpoint,
      ) ??
      borderRadius;

  borderRadiusBottomRight = doubleValueResolver(
        styleSheet.borderRadiusBottomRight,
        borderRadiusBottomRight,
        activeBreakpoint,
      ) ??
      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);

  // [fontSize]
  fontSize = doubleValueResolver(
    styleSheet.fontSize,
    fontSize,
    activeBreakpoint,
  );

  // [fontWeight]
  var fontWeightMap = {
    'normal': FontWeight.normal,
    'bold': FontWeight.bold,
    '100': FontWeight.w100,
    '200': FontWeight.w200,
    '300': FontWeight.w300,
    '400': FontWeight.w400,
    '500': FontWeight.w500,
    '600': FontWeight.w600,
    '700': FontWeight.w700,
    '800': FontWeight.w800,
    '900': FontWeight.w900,
  };
  fontWeight = fontWeightMap[
      resolveValueForBreakpoint(styleSheet.fontWeight, activeBreakpoint) ??
          fontWeight];
}