grid method

Widget grid()

Implementation

Widget grid() {
  var today = DateTime.now();
  int todayD = today.day;
  int todayYm = today.year * 12 + today.month;
  int y = dateEdit.year;
  int m = dateEdit.month;
  int d = dateEdit.day;
  int sy = date.year;
  int sm = date.month;

  Cal di = Cal(dateEdit);
  var rows = di.getGrid();
  return Expanded(
    child: Column(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: rows.map<Widget>((l) {
        return Expanded(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: l.map<Widget>((v) {
              var v0 = v[0];
              var v1 = v[1];
              Color color;
              if (v1 == 0) {
                if (d == v0 && y == sy && m == sm) {
                  color = selectedDayColor;
                } else if (todayD == v0 && todayYm == y * 12 + m) {
                  color = todayColor;
                } else {
                  color = currentMonthDayColor;
                }
              } else {
                color = otherMonthDayColor;
              }
              return Expanded(
                  child: Container(
                color: (v1 == 0 && y == sy && m == sm && d == v0)
                    ? selectedDayBgColor
                    : null,
                child: Center(
                  child: TextButton(
                    onPressed: () => onCellTap(v1, v0, context),
                    child: Text('${v[0]}',
                        softWrap: false,
                        textAlign: TextAlign.center,
                        style:
                            TextStyle(fontSize: gridFontSize, color: color)),
                  ),
                ),
              ));
            }).toList(),
          ),
        );
      }).toList(),
    ),
  );
}