removed unneeded 'new' everywhere
This commit is contained in:
parent
88eb570f63
commit
d78746fa87
4 changed files with 58 additions and 58 deletions
|
@ -11,7 +11,7 @@ class YearsPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _YearsPageState extends State<YearsPage> {
|
||||
int _year = new DateTime.now().year;
|
||||
int _year = DateTime.now().year;
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
return Scaffold(
|
||||
|
@ -20,18 +20,18 @@ class _YearsPageState extends State<YearsPage> {
|
|||
title: Text("Years"),
|
||||
),
|
||||
body: Center(
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new NumberPicker.integer(
|
||||
NumberPicker.integer(
|
||||
initialValue: _year, // TODO set to current year
|
||||
minValue: 1800,
|
||||
maxValue: 2399,
|
||||
onChanged: (newYear) =>
|
||||
setState(() => _year = newYear),
|
||||
),
|
||||
new Text("You picked the year: $_year"),
|
||||
new Text("The century code is: " + DayCalculator.getCenturyValue(_year).toString()),
|
||||
new Text("Is this a leap year: " + DayCalculator.isLeapYear(_year).toString()),
|
||||
Text("You picked the year: $_year"),
|
||||
Text("The century code is: " + DayCalculator.getCenturyValue(_year).toString()),
|
||||
Text("Is this a leap year: " + DayCalculator.isLeapYear(_year).toString()),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
|
|
@ -19,20 +19,20 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
int _correct = 0;
|
||||
int _incorrect = 0;
|
||||
bool _showCorrect = true;
|
||||
static final _random = new Random();
|
||||
static final _random = Random();
|
||||
Month _month = Months.getFromInt(_random.nextInt(Months.length));
|
||||
List<MonthPracticeAnswer> answers = new List<MonthPracticeAnswer>();
|
||||
List<MonthPracticeAnswer> answers = List<MonthPracticeAnswer>();
|
||||
|
||||
Widget getAnswerRow(){
|
||||
List<Widget> answerBoxes = new List<Widget>();
|
||||
List<Widget> answerBoxes = List<Widget>();
|
||||
for(MonthPracticeAnswer answer in answers){
|
||||
Color c = Colors.green;
|
||||
if(answer.month.value != answer.answer){
|
||||
c = Colors.red;
|
||||
}
|
||||
answerBoxes.add(
|
||||
new Expanded(
|
||||
child: new Container(
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 50,
|
||||
color: c
|
||||
)
|
||||
|
@ -41,15 +41,15 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
}
|
||||
for(int i in Iterable.generate(_startCount - _count)) {
|
||||
answerBoxes.add(
|
||||
new Expanded(
|
||||
child: new Container(
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 50,
|
||||
color: Colors.blue,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
return new Row(children: answerBoxes);
|
||||
return Row(children: answerBoxes);
|
||||
}
|
||||
|
||||
Widget getQuestions(){
|
||||
|
@ -61,9 +61,9 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
tmp.write(": ${answer.month.value}");
|
||||
}
|
||||
questions.add(
|
||||
new Opacity(
|
||||
Opacity(
|
||||
opacity: 0.3,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
tmp.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
|
@ -74,9 +74,9 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
);
|
||||
} else {
|
||||
questions.add(
|
||||
new Opacity(
|
||||
Opacity(
|
||||
opacity: 0.6,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
"-",
|
||||
style: TextStyle(fontSize: 10)
|
||||
)
|
||||
|
@ -90,9 +90,9 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
tmp.write(": ${answer.month.value}");
|
||||
}
|
||||
questions.add(
|
||||
new Opacity(
|
||||
Opacity(
|
||||
opacity: 0.6,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
tmp.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
|
@ -103,9 +103,9 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
);
|
||||
} else {
|
||||
questions.add(
|
||||
new Opacity(
|
||||
Opacity(
|
||||
opacity: 0.6,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
"-",
|
||||
style: TextStyle(fontSize: 15)
|
||||
)
|
||||
|
@ -113,40 +113,40 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
);
|
||||
}
|
||||
questions.add(
|
||||
new Text(
|
||||
Text(
|
||||
_month.string.capitalize(),
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Column(
|
||||
return Column(
|
||||
children: questions
|
||||
);
|
||||
}
|
||||
|
||||
Widget getButtons(){
|
||||
List<Widget> buttons = new List<Widget>();
|
||||
List<Widget> buttons = List<Widget>();
|
||||
for(int i in [1,2,3,4,5,6,-1,0,-1]){
|
||||
if (i == -1){
|
||||
buttons.add(Container());
|
||||
continue;
|
||||
}
|
||||
buttons.add(
|
||||
new FlatButton(
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
checkMonth(i);
|
||||
},
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
child: new Text(
|
||||
child: Text(
|
||||
i.toString(),
|
||||
style: TextStyle(fontSize: 30)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
return new GridView.count(
|
||||
return GridView.count(
|
||||
primary: false,
|
||||
crossAxisCount: 3,
|
||||
padding: EdgeInsets.fromLTRB(0, 20, 0, 20),
|
||||
|
@ -168,26 +168,26 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
title: Text("Practicing months"),
|
||||
),
|
||||
body: Center(
|
||||
child: new Container(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
Text(
|
||||
"Correct: " + _correct.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
)
|
||||
),
|
||||
new Text(
|
||||
Text(
|
||||
(_startCount - _count).toString() + " Left",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
)
|
||||
),
|
||||
new Text(
|
||||
Text(
|
||||
"Incorrect: " + _incorrect.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
|
@ -197,7 +197,7 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
),
|
||||
getQuestions(),
|
||||
getButtons(),
|
||||
new Align(
|
||||
Align(
|
||||
alignment: FractionalOffset.bottomCenter,
|
||||
child: getAnswerRow()
|
||||
)
|
||||
|
@ -215,7 +215,7 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
_incorrect += 1;
|
||||
}
|
||||
_count += 1;
|
||||
answers.add(new MonthPracticeAnswer(_month, answer));
|
||||
answers.add(MonthPracticeAnswer(_month, answer));
|
||||
if((_startCount - _count) == 0) {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
|
|
|
@ -19,24 +19,24 @@ class _MonthPracticeSetupState extends State<MonthPracticeSetupPage> {
|
|||
title: Text("Practice Months"),
|
||||
),
|
||||
body: Center(
|
||||
child: new Container(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
Text(
|
||||
"How many rounds?",
|
||||
style: TextStyle(fontSize: 30),
|
||||
),
|
||||
new NumberPicker.integer(
|
||||
NumberPicker.integer(
|
||||
initialValue: _count,
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
onChanged: (newNumber) =>
|
||||
setState(() => _count = newNumber),
|
||||
),
|
||||
new SizedBox(height: 30),
|
||||
new CheckboxListTile(
|
||||
title: new Text("Show correct Answer"),
|
||||
SizedBox(height: 30),
|
||||
CheckboxListTile(
|
||||
title: Text("Show correct Answer"),
|
||||
value: _showCorrect,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
|
@ -44,8 +44,8 @@ class _MonthPracticeSetupState extends State<MonthPracticeSetupPage> {
|
|||
});
|
||||
}
|
||||
),
|
||||
new SizedBox(height: 30),
|
||||
new FlatButton(
|
||||
SizedBox(height: 30),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
|
@ -53,7 +53,7 @@ class _MonthPracticeSetupState extends State<MonthPracticeSetupPage> {
|
|||
arguments: MonthPracticeSetup(_count, _showCorrect)
|
||||
);
|
||||
},
|
||||
child: new Text("Start!"),
|
||||
child: Text("Start!"),
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
padding: EdgeInsets.all(8.0)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
class Months {
|
||||
static final Month january = new Month("january", 0, 0);
|
||||
static final Month february = new Month("february", 1, 3);
|
||||
static final Month march = new Month("march", 2, 3);
|
||||
static final Month april = new Month("april", 3, 6);
|
||||
static final Month may = new Month("may", 4, 1);
|
||||
static final Month june = new Month("june", 5, 4);
|
||||
static final Month july = new Month("july", 6, 6);
|
||||
static final Month august = new Month("august", 7, 2);
|
||||
static final Month september = new Month("september", 8, 5);
|
||||
static final Month october = new Month("october", 9, 0);
|
||||
static final Month november = new Month("november", 10, 3);
|
||||
static final Month december = new Month("december", 11, 5);
|
||||
static final Month january = Month("january", 0, 0);
|
||||
static final Month february = Month("february", 1, 3);
|
||||
static final Month march = Month("march", 2, 3);
|
||||
static final Month april = Month("april", 3, 6);
|
||||
static final Month may = Month("may", 4, 1);
|
||||
static final Month june = Month("june", 5, 4);
|
||||
static final Month july = Month("july", 6, 6);
|
||||
static final Month august = Month("august", 7, 2);
|
||||
static final Month september = Month("september", 8, 5);
|
||||
static final Month october = Month("october", 9, 0);
|
||||
static final Month november = Month("november", 10, 3);
|
||||
static final Month december = Month("december", 11, 5);
|
||||
|
||||
static final int length = 12;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue