build method
- dynamic context
override
Implementation
@override
pw.Widget build(dynamic context) {
return pw.Column(
children: [
Header(data: data),
pw.Flexible(
child: pw.Row(children: [
body,
pw.Container(
width: 7.5 * PdfPageFormat.cm,
margin: const pw.EdgeInsets.only(top: PdfPageFormat.mm * 7),
padding: const pw.EdgeInsets.symmetric(
vertical: PdfPageFormat.mm * 1),
alignment: pw.Alignment.centerLeft,
child: pw.Column(
mainAxisAlignment: pw.MainAxisAlignment.start,
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [
pw.Text("FHR1",
style: pw.TextStyle(
color: PdfColors.teal,
fontSize: 12,
fontWeight: pw.FontWeight.normal,
letterSpacing: 1.0),
textAlign: pw.TextAlign.left),
pw.SizedBox(height: PdfPageFormat.mm * 1.5),
pw.Row(
children: [
pw.RichText(
text: pw.TextSpan(
text: "BASAL HR",
children: const [
pw.TextSpan(
text: "\nACCELERATION",
),
pw.TextSpan(
text: "\nDECELERATION",
),
pw.TextSpan(
text: "\nMOVEMENTS",
),
pw.TextSpan(
text: "\nFISHER SCORE",
),
pw.TextSpan(
text: "\nSHORT TERM VARI ",
),
pw.TextSpan(
text: "\nLONG TERM VARI ",
),
],
style: pw.TextStyle(
fontSize: 10,
color: PdfColors.grey,
lineSpacing: PdfPageFormat.mm * 1.5,
fontWeight: pw.FontWeight.bold),
),
textAlign: pw.TextAlign.left,
),
pw.RichText(
text: pw.TextSpan(
text:
": ${(interpretation?.basalHeartRate ?? "--")} bpm",
children: [
pw.TextSpan(
text:
"\n: ${(interpretation?.getnAccelerationsStr() ?? "--")}",
),
pw.TextSpan(
text:
"\n: ${(interpretation?.getnDecelerationsStr() ?? "--")}",
),
pw.TextSpan(
text:
"\n: ${(data.movementEntries?.length)} manual / ${(data.autoFetalMovement?.length)} auto",
),
pw.TextSpan(
text:
"\n: ${(interpretation?.fisherScore)}", //todo need to verify
),
pw.TextSpan(
text:
"\n: ${(interpretation?.getShortTermVariationBpmStr() ?? "--")} bpm /${(interpretation?.getShortTermVariationMilliStr() ?? "--")} milli",
),
pw.TextSpan(
text:
"\n: ${(interpretation?.getLongTermVariationStr() ?? "--")} bpm",
),
],
style: pw.TextStyle(
fontSize: 10,
lineSpacing: PdfPageFormat.mm * 1.5,
fontWeight: pw.FontWeight.bold),
),
textAlign: pw.TextAlign.left,
/*
style: pw.TextStyle(
fontSize: 16,
color: PdfColors.white,
fontWeight: pw.FontWeight.bold),*/
),
],
),
pw.SizedBox(height: PdfPageFormat.mm * 4),
pw.Text("FHR2",
style: pw.TextStyle(
color: PdfColors.teal,
fontSize: 12,
fontWeight: pw.FontWeight.bold,
letterSpacing: 1.0),
textAlign: pw.TextAlign.left),
pw.SizedBox(height: PdfPageFormat.mm * 1.5),
pw.Row(
children: [
pw.RichText(
text: pw.TextSpan(
text: "BASAL HR",
children: const [
pw.TextSpan(
text: "\nACCELERATION",
),
pw.TextSpan(
text: "\nDECELERATION",
),
pw.TextSpan(
text: "\nFISHER SCORE",
),
pw.TextSpan(
text: "\nSHORT TERM VARI ",
),
pw.TextSpan(
text: "\nLONG TERM VARI ",
),
],
style: pw.TextStyle(
fontSize: 10,
color: PdfColors.grey,
lineSpacing: PdfPageFormat.mm * 1.5,
fontWeight: pw.FontWeight.bold),
),
textAlign: pw.TextAlign.left,
),
pw.RichText(
text: pw.TextSpan(
text:
": ${(interpretation2?.basalHeartRate ?? "--")}",
children: [
pw.TextSpan(
text:
"\n: ${(interpretation2?.getnAccelerationsStr() ?? "--")}",
),
pw.TextSpan(
text:
"\n: ${(interpretation2?.getnDecelerationsStr() ?? "--")}",
),
pw.TextSpan(
text:
"\n: ${(interpretation2?.fisherScore ?? "--")}", //todo need to check here MP
),
pw.TextSpan(
text:
"\n: ${(interpretation2?.getShortTermVariationBpmStr() ?? "--")}/${(interpretation2?.getShortTermVariationMilliStr() ?? "--")}",
),
pw.TextSpan(
text:
"\n: ${(interpretation2?.getLongTermVariationStr() ?? "--")}",
),
],
style: pw.TextStyle(
fontSize: 10,
lineSpacing: PdfPageFormat.mm * 1.5,
fontWeight: pw.FontWeight.bold),
),
textAlign: pw.TextAlign.left,
/*
style: pw.TextStyle(
fontSize: 16,
color: PdfColors.white,
fontWeight: pw.FontWeight.bold),*/
),
],
),
pw.SizedBox(height: PdfPageFormat.mm * 4),
pw.Text("NOTES",
style: pw.TextStyle(
color: PdfColors.teal,
fontSize: 12,
fontWeight: pw.FontWeight.bold,
letterSpacing: 1.0),
textAlign: pw.TextAlign.left),
pw.SizedBox(height: PdfPageFormat.mm * 2),
pw.RichText(
text: pw.TextSpan(
text: "______________________________________",
children: const [
pw.TextSpan(
text: "\n______________________________________",
),
pw.TextSpan(
text: "\n______________________________________",
),
pw.TextSpan(
text: "\n______________________________________",
),
],
style: pw.TextStyle(
fontSize: 10,
lineSpacing: PdfPageFormat.mm * 1.5,
fontWeight: pw.FontWeight.bold),
),
textAlign: pw.TextAlign.left,
),
pw.SizedBox(height: PdfPageFormat.mm * 5),
pw.TableHelper.fromTextArray(
border: pw.TableBorder.all(color: PdfColors.grey),
// Adds border to the entire table
headerStyle: const pw.TextStyle(fontSize: 6),
headerAlignment: pw.Alignment.centerLeft,
// Custom font for headers
cellPadding: const pw.EdgeInsets.symmetric(
horizontal: 4, vertical: 2),
cellStyle: const pw.TextStyle(fontSize: 6),
headers: [
"Baseline freq",
"<10 or >180",
"100-10/160-180",
"100-160"
],
//List<String>.generate(3, (col) => 'Header ${col + 1}'), // Optionally, you can add headers
data: [
["Bandwidth", "< 5", "5-10 or 03>", "10 - 30"],
["Zero cross", "< 2", "2 - 6", "> 6"],
["Accelerations", "Absent", "Regular", "Sporadic"],
[
"Deceleration",
"Unfavorable",
"Less severe",
"Absent"
]
], //["Bandwidth","Zero cross","Accelerations", "Deceleration"],["Bandwidth","Zero cross","Accelerations", "Deceleration"],
),
pw.SizedBox(height: PdfPageFormat.mm * 2),
]),
),
]),
fit: pw.FlexFit.tight),
Footer(page: index, total: total),
],
);
}