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