Moved MonthValuesPage class to it's own file
This commit is contained in:
parent
509146634d
commit
ee2b55de42
2 changed files with 57 additions and 52 deletions
55
lib/MonthValuesPage.dart
Normal file
55
lib/MonthValuesPage.dart
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MonthValuesPage extends StatelessWidget {
|
||||||
|
final Map<String, int> 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<String, int> 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()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'MonthValuesPage.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(OhThatsA());
|
runApp(OhThatsA());
|
||||||
}
|
}
|
||||||
|
@ -15,56 +17,4 @@ class OhThatsA extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MonthValuesPage extends StatelessWidget {
|
|
||||||
final Map<String, int> 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<String, int> 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()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue