Skip to content

Instantly share code, notes, and snippets.

@kirshiyin89
Created August 24, 2020 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirshiyin89/50bc5863d2da6f4c23c6fa224c807868 to your computer and use it in GitHub Desktop.
Save kirshiyin89/50bc5863d2da6f4c23c6fa224c807868 to your computer and use it in GitHub Desktop.
Creating the Table Widget.
Widget _createStatusTable(ServerInfo serverInfo) {
if (serverInfo.notAvailable()) {
return new Text('Server unreachable');
}
return Table(
border: TableBorder.all(
color: Colors.black26, width: 1, style: BorderStyle.none),
children: _createStatusCells(serverInfo.services));
}
List<TableCell> _prepareHeader() {
final TextStyle textStyle = TextStyle(fontWeight: FontWeight.bold);
return [
TableCell(
child: Padding(
padding: EdgeInsets.only(left: 20),
child: Text("SERVICE", style: textStyle))),
TableCell(child: Center(child: Text("STATUS", style: textStyle)))
];
}
List<TableRow> _createStatusCells(List<ServiceInfo> serviceInfo) {
List<TableRow> rows = [];
// prepare header
rows.add(TableRow(children: _prepareHeader()));
// prepare data
for (ServiceInfo info in serviceInfo) {
rows.add(TableRow(children: [
TableCell(
child: Padding(
padding: EdgeInsets.only(left: 20),
child: Text(info.name, textAlign: TextAlign.left))),
TableCell(
child: Center(
child: Text(info.status(),
style: _getStyleByServiceStatus(info.running))))
]));
}
return rows;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment