breakpointComparator static method

int breakpointComparator(
  1. ResponsiveBreakpoint a,
  2. ResponsiveBreakpoint b
)

Comparator function to order ResponsiveBreakpoints.

Order breakpoints from smallest to largest based on breakpoint value. When breakpoint values are equal, map ResponsiveBreakpointBehavior to their ordering value in breakpointCompartorList and compare.

Implementation

static int breakpointComparator(
    ResponsiveBreakpoint a, ResponsiveBreakpoint b) {
  // If breakpoints are equal, return in comparator order.
  if (a.breakpoint == b.breakpoint) {
    return breakpointCompartorList[a.behavior]!
        .compareTo(breakpointCompartorList[b.behavior]!);
  }

  // Breakpoints are not equal can be compared directly.
  return a.breakpoint.compareTo(b.breakpoint);
}