json_table
json_table copied to clipboard
Text Formatting for the Columns?
Excellent library. Thanks for the hard work!
I'm looking for a way to bold or italicize text in one of the columns. Am I missing something or is this not something that can be done at this time?
You can use tablecellBUilder function to customize a cell widget
I am using a small amount of data, so was able to use .contains(x) on a list; however, on larger datasets, do you have a thought on how to identify a column alone vs each value in the columns?
I was thinking of an extra parameter in here for example:
JsonTableColumn("DOB", label: "Date of Birth", valueBuilder: formatDOB, columnFormatting: formatColumn1),
Here is what I did:
var botanicalNames = ['Baikiaea plurijuga', 'Pterocarpus angolensis', 'Guibourtia coleosperma', 'Afzelia quanzensis', 'Colophospermum mopane', 'Erythrophleum africanum', 'Brachystegia spiciformis', 'Julbernardia paniculata', 'None', 'Burkea africana', 'Terminalia sericea', 'Pterocarpus tinctorius', 'Kirkia acuminata'];
return JsonTable(
timberdata,
tableCellBuilder: (value) {
if (botanicalNames.contains(value)) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
decoration: BoxDecoration(border: Border.all(width: 0.5, color: Colors.grey.withOpacity(0.5))),
child: Text(
value,
textAlign: TextAlign.left,
style: TextStyle(fontStyle: FontStyle.italic),
),
);
} else {
return Container(
padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
decoration: BoxDecoration(border: Border.all(width: 0.5, color: Colors.grey.withOpacity(0.5))),
child: Text(
value,
textAlign: TextAlign.left,
style: TextStyle(fontStyle: FontStyle.normal),
),
);
}
},
columns: columns,
allowRowHighlight: true,
);