diff --git a/lib/main.dart b/lib/main.dart index 2add021..69c1117 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -28,35 +28,19 @@ class MonthValuesPage extends StatelessWidget { "December": 5, }; - List getMonthValueWidget(){ - var monthWidgets = List(); - monthValues.forEach((key, value) { - monthWidgets.add( - Row( - children: [ - Container( - alignment: Alignment.center, - child: Text( - key, - style: TextStyle( - fontSize: 35 - ) - ) - ), - Container( - alignment: Alignment.centerRight, - child: Text( - value.toString(), - style: TextStyle( - fontSize: 35 - ) - ) - ) - ], + final monthTableRowTextStyle = TextStyle(fontSize: 35); + + TableRow getMonthTableRow(MapEntry month) { + return TableRow( + children: [ + TableCell( + child: Text(month.key, style: monthTableRowTextStyle) + ), + TableCell( + child: Text(month.value.toString(), style: monthTableRowTextStyle) ) - ); - }); - return monthWidgets; + ] + ); } @override @@ -67,8 +51,8 @@ class MonthValuesPage extends StatelessWidget { appBar: AppBar( title: Text("Month Values") ), - body: Column( - children: this.getMonthValueWidget() + body: Table( + children: monthValues.entries.map(getMonthTableRow).toList() ) ), );