buildDataRow method

DataRow buildDataRow(
  1. BuildContext context,
  2. int idx,
  3. List<Map> selectionList,
  4. bool multiSelect,
  5. Function? selectFunction,
  6. StateSetter setState,
)

Implementation

DataRow buildDataRow(BuildContext context, int idx, List<Map> selectionList,
    bool multiSelect, Function? selectFunction, StateSetter setState) {
  final entry = mutable.lastState.fullData[idx];
  final rowColor = tryParseColor(props["rowColor"]);
  final rowOddColor = tryParseColor(props["rowOddColor"]) ?? rowColor;
  final color = idx.isEven ? rowColor : rowOddColor;

  return DataRow(
    color: color != null
        ? WidgetStateColor.resolveWith((states) => color)
        : null,
    selected: selectionList.contains(entry),
    cells: buildDataCells(context, idx),
    onSelectChanged: (val) => setState(() {
      if (!multiSelect) {
        selectionList.clear();
      }
      if (val == true) {
        selectionList.add(entry);
      } else {
        selectionList.remove(entry);
      }
      if (selectFunction != null) {
        selectFunction(entry);
      }
    }),
  );
}