Created
August 24, 2020 18:57
-
-
Save kirshiyin89/50bc5863d2da6f4c23c6fa224c807868 to your computer and use it in GitHub Desktop.
Creating the Table Widget.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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