From ee2b55de429b5d31c06ce6da20adedc0ee8bff3f Mon Sep 17 00:00:00 2001 From: broodjeaap Date: Thu, 11 Jun 2020 21:18:07 +0200 Subject: [PATCH] Moved MonthValuesPage class to it's own file --- lib/MonthValuesPage.dart | 55 ++++++++++++++++++++++++++++++++++++++++ lib/main.dart | 54 ++------------------------------------- 2 files changed, 57 insertions(+), 52 deletions(-) create mode 100644 lib/MonthValuesPage.dart diff --git a/lib/MonthValuesPage.dart b/lib/MonthValuesPage.dart new file mode 100644 index 0000000..c1df76d --- /dev/null +++ b/lib/MonthValuesPage.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; + +class MonthValuesPage extends StatelessWidget { + final Map monthValues = { + "January": 0, + "February": 3, + "March": 3, + "April": 6, + "May": 1, + "June": 4, + "July": 6, + "August": 2, + "September": 5, + "October": 0, + "November": 3, + "December": 5, + }; + + final monthTableRowTextStyle = TextStyle(fontSize: 35); + + TableRow getMonthTableRow(MapEntry month) { + return TableRow( + children: [ + TableCell( + child: Text( + month.key, + style: monthTableRowTextStyle, + textAlign: TextAlign.right + ) + ), + TableCell( + child: Text( + month.value.toString(), + style: monthTableRowTextStyle, + textAlign: TextAlign.center + ) + ) + ] + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Month Values") + ), + body: Center( + child: Table( + children: monthValues.entries.map(getMonthTableRow).toList() + ) + ) + ); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index eac312b..9b9650b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'MonthValuesPage.dart'; + void main() { runApp(OhThatsA()); } @@ -15,56 +17,4 @@ class OhThatsA extends StatelessWidget { } } -class MonthValuesPage extends StatelessWidget { - final Map monthValues = { - "January": 0, - "February": 3, - "March": 3, - "April": 6, - "May": 1, - "June": 4, - "July": 6, - "August": 2, - "September": 5, - "October": 0, - "November": 3, - "December": 5, - }; - final monthTableRowTextStyle = TextStyle(fontSize: 35); - - TableRow getMonthTableRow(MapEntry month) { - return TableRow( - children: [ - TableCell( - child: Text( - month.key, - style: monthTableRowTextStyle, - textAlign: TextAlign.right - ) - ), - TableCell( - child: Text( - month.value.toString(), - style: monthTableRowTextStyle, - textAlign: TextAlign.center - ) - ) - ] - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text("Month Values") - ), - body: Center( - child: Table( - children: monthValues.entries.map(getMonthTableRow).toList() - ) - ) - ); - } -}