adaptesGridCrossAxisCount function

int adaptesGridCrossAxisCount(
  1. BoxConstraints constraints
)

根据宽度约束布局最大宽度

Implementation

int adaptesGridCrossAxisCount(BoxConstraints constraints) {
  int maxWidth = 2;
  if (constraints.maxWidth > kExtraLargeWidthBreakpoint) {
    maxWidth = 6;
  } else if (constraints.maxWidth > kLargeWidthBreakpoint) {
    maxWidth = 4;
  } else if (constraints.maxWidth > kMediumWidthBreakpoint) {
    maxWidth = 3;
  } else if (constraints.maxWidth > kSmallWidthBreakpoint) {
    maxWidth = 2;
  }
  return maxWidth;
}