From 0842a588655d6e061a34ddf52610b0416f151286 Mon Sep 17 00:00:00 2001 From: broodjeaap Date: Mon, 8 Jun 2020 20:52:11 +0200 Subject: [PATCH] table of month values --- lib/main.dart | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) 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() ) ), );