buildDisplayRow function
- required BuildContext context,
- required BPObservation observation,
- required int index,
- required VoidCallback onEdit,
- required VoidCallback onDelete,
Creates a read-only DataRow for displaying a single BPObservation.
This row shows the observation's timestamp, systolic pressure, diastolic
pressure, heart rate, feeling, and notes. It also provides an edit button
(onEdit
) and a delete button (onDelete
) for user interactions.
The index
can help identify the observation's position in the parent list.
The context
is used for resolving localizations, themes, or showing UI
feedback (e.g. snack bars).
Returns:
Implementation
DataRow buildDisplayRow({
required BuildContext context,
required BPObservation observation,
required int index,
required VoidCallback onEdit,
required VoidCallback onDelete,
}) {
return DataRow(
cells: [
// Timestamp cell.
DataCell(
Text(DateFormat('yyyy-MM-dd HH:mm:ss').format(observation.timestamp)),
),
// Systolic cell.
DataCell(Text(parseNumericInput(observation.systolic))),
// Diastolic cell.
DataCell(Text(parseNumericInput(observation.diastolic))),
// Heart rate cell.
DataCell(Text(parseNumericInput(observation.heartRate))),
// Feeling cell.
DataCell(Text(observation.feeling)),
// Notes cell (with a max width to limit horizontal space usage).
DataCell(
Container(
constraints: const BoxConstraints(maxWidth: 200),
child: Text(
observation.notes,
overflow: TextOverflow.ellipsis,
maxLines: 3,
),
),
),
// Actions cell: edit and delete icons.
DataCell(
Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.edit),
onPressed: onEdit,
),
IconButton(
icon: const Icon(Icons.delete),
onPressed: onDelete,
),
],
),
),
],
);
}