monthsWidgetMaker method

List<TableRow> monthsWidgetMaker(
  1. dynamic context
)

Implementation

List<TableRow> monthsWidgetMaker(context) {
  months = Translator.getFullMonthNames();

  List<Widget> _buildRowCells(int rowIndex) {
    List<TableCell> widgets = [];
    for (var j = 0; j < 3; j++) {
      final int mMonth = (rowIndex * 3) + j + 1;
      widgets.add(
        TableCell(
          verticalAlignment: TableCellVerticalAlignment.middle,
          child: Material(
            color: Colors.transparent,
            child: InkWell(
              onTap: (() {
                Navigator.pop(context);
                onHeaderChanged.call(mMonth);
              }),
              child: Container(
                padding: EdgeInsets.all(15),
                decoration: mMonth == currentMonth ? selectedDecoration : null,
                child: Center(
                    child: FittedBox(
                  fit: BoxFit.fitWidth,
                  child: Text(
                    months[(rowIndex * 3) + j].toString(),
                    style: TextStyle(
                      fontSize: 16,
                      color: mMonth == currentMonth ? Colors.white : null,
                      fontFamily: monthStyle?.font,
                    ),
                    maxLines: 1,
                  ),
                )),
              ),
            ),
          ),
        ),
      );
    }
    return widgets;
  }

  List<TableRow> monthsWidget = [];
  for (var i = 0; i < 4; i++) {
    monthsWidget.add(TableRow(children: _buildRowCells(i)));
  }

  return monthsWidget;
}