layoutItemWidth method

double layoutItemWidth(
  1. int sections,
  2. Size area
)

Returns a maximum width accounting for padding, given how many rows, and depending on device type.

Implementation

double layoutItemWidth(int sections, Size area) {
  double sizingWidth = 0.0;

  if (sections == 1) {
    //item needs to be full width with w1 padding

    isDesktopDisplay(area) == false
        ? sizingWidth = area.width * 0.90
        : sizingWidth = area.width * 0.60;
  } else if (sections == 2) {
    //item needs to be 1/2 width for 2 sections

    isDesktopDisplay(area) == false
        ? sizingWidth = area.width * 0.45
        : sizingWidth = area.width * 0.30;
  } else if (sections == 3) {
    //item needs to be 1/3 width for 3 sections
    isDesktopDisplay(area) == false
        ? sizingWidth = area.width * 0.33
        : sizingWidth = area.width * 0.12;
  } else if (sections == 4) {
    //item needs to be 1/4 width for 4 sections
    isDesktopDisplay(area) == false
        ? sizingWidth = area.width * 0.24
        : sizingWidth = area.width * 0.092;
  } else if (sections == 5) {
    //item needs to be 1/5 width for 5 sections
    isDesktopDisplay(area) == false
        ? sizingWidth = area.width * 0.21
        : sizingWidth = area.width * 0.080;
  }
  return sizingWidth;
}