buildDataTable method
Implementation
DataTable buildDataTable(BuildContext context, StateSetter setState) {
Function? selectFunction;
if (!EditorBloc.editMode) {
selectFunction = Lowder.actions.getValueFunction<Map>(
context, actions["onSelect"], state, evaluatorContext);
}
final alias = props["alias"] ?? id;
final selectionType = props["selectionType"];
final multiSelect = selectionType == "multiple";
final selectable = multiSelect || selectionType == "single";
final dataRowColor = tryParseColor(props["dataRowColor"]);
final headingRowColor = tryParseColor(props["headingRowColor"]);
return DataTable(
key: Key("${id}_list"),
showCheckboxColumn: selectable,
decoration: spec.buildProp("decoration"),
border: spec.buildProp("border"),
dividerThickness: tryParseDouble(props["dividerThickness"]),
columnSpacing: tryParseDouble(props["columnSpacing"]),
checkboxHorizontalMargin:
tryParseDouble(props["checkboxHorizontalMargin"]),
horizontalMargin: tryParseDouble(props["horizontalMargin"]),
showBottomBorder: parseBool(props["showBottomBorder"]),
headingRowColor: headingRowColor != null
? MaterialStateColor.resolveWith((states) => headingRowColor)
: null,
headingRowHeight: tryParseDouble(props["headingRowHeight"]),
headingTextStyle: spec.buildProp("headingTextStyle"),
dataRowColor: dataRowColor != null
? MaterialStateColor.resolveWith((states) => dataRowColor)
: null,
dataRowMinHeight: tryParseDouble(props["dataRowHeight"]),
dataTextStyle: spec.buildProp("dataTextStyle"),
onSelectAll: !multiSelect
? null
: (val) => setState(() {
state[alias].clear();
if (val == true) {
state[alias].addAll(mutable.lastState.fullData);
}
}),
sortColumnIndex: sortState["idx"],
sortAscending: parseBool(sortState["asc"], defaultValue: true),
columns: buildDataColumns(context, setState),
rows: List<DataRow>.generate(
mutable.lastState.fullData.length,
(idx) => buildDataRow(
context, idx, state[alias], multiSelect, selectFunction, setState),
),
);
}