buildRow method
DataRow
buildRow({})
Implementation
DataRow buildRow({
required Map<String, dynamic> objectAsJson,
required FieldPressedCallback onFieldPressed,
required int cellsNumber,
required int objectIndex,
required void Function({
required bool selected,
required int index,
})
onSelectRow,
required bool isSelected,
required bool enableSelection,
required List<String> keys,
}) {
String dataCellValue(
dynamic field,
) {
if (field.runtimeType == List<Map<String, dynamic>>) {
return 'List OF Objects';
} else if (isMap(field)) {
return "Object";
} else if (isList(field)) {
return 'List';
} else {
return field.toString();
}
}
List<String> rowKeys = [];
rowKeys = keys;
return DataRow(
onSelectChanged: !enableSelection
? null
: (isSelected) =>
onSelectRow(selected: isSelected!, index: objectIndex),
selected: isSelected,
cells: rowKeys.map<DataCell>((fieldName) {
final cellValue = dataCellValue(objectAsJson[fieldName]);
final isList = cellValue == 'List';
return DataCell(
onLongPress: () {
final value = objectAsJson[fieldName];
final json = const JsonEncoder.withIndent(' ').convert(value);
FlutterClipboardHiveUi.copy(json);
},
Center(
child: Text(
cellValue,
),
),
onTap: () => !isList
? onFieldPressed(
"boxName",
fieldName,
objectAsJson,
objectIndex: objectIndex,
)
: showListDetailsDialog(
fieldName,
objectAsJson[fieldName] as List,
),
);
}).toList(),
);
}