useColumns static method
The static helper function useColumns is used with grid and column layouts to reduce the amount of columns used in the layout compared
In the other version useColumns, give it the columns from your
Breakpoint layout and provide it an int divisor
with a value
from 1 to 24. It returns the floor of the columns divided with divisor
.
It always returns at least 1 as the columns to use.
Implementation
static int useColumns(int availableColumns, int divisor) {
// It is bad style to modify passed in parameters, so we make local
// copies that we modify as needed for validity checks.
int usableColumns = availableColumns;
int divideBy = divisor;
if (usableColumns < 1 || usableColumns > 24) usableColumns = 1;
if (divideBy < 1 || divideBy > 24) divideBy = 1;
return (usableColumns / divideBy).floor() < 1
? 1
: (usableColumns / divideBy).floor();
}