From d78746fa87b80c528fe3fd3a2ab92b570d575f08 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Tue, 20 Oct 2020 17:02:21 +0200 Subject: [PATCH] removed unneeded 'new' everywhere --- lib/pages/YearsPage.dart | 12 ++-- .../practice/month/MonthPracticePage.dart | 60 +++++++++---------- .../month/MonthPracticeSetupPage.dart | 20 +++---- lib/util/Months.dart | 24 ++++---- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/lib/pages/YearsPage.dart b/lib/pages/YearsPage.dart index 5898d1a..a919841 100644 --- a/lib/pages/YearsPage.dart +++ b/lib/pages/YearsPage.dart @@ -11,7 +11,7 @@ class YearsPage extends StatefulWidget { } class _YearsPageState extends State { - 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 { title: Text("Years"), ), body: Center( - child: new Column( + child: Column( children: [ - 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()), ] ) ) diff --git a/lib/pages/practice/month/MonthPracticePage.dart b/lib/pages/practice/month/MonthPracticePage.dart index ae7a0bf..414d187 100644 --- a/lib/pages/practice/month/MonthPracticePage.dart +++ b/lib/pages/practice/month/MonthPracticePage.dart @@ -19,20 +19,20 @@ class _MonthPracticeState extends State { 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 answers = new List(); + List answers = List(); Widget getAnswerRow(){ - List answerBoxes = new List(); + List answerBoxes = List(); 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 { } 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 { 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 { ); } 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 { 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 { ); } 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 { ); } questions.add( - new Text( + Text( _month.string.capitalize(), style: TextStyle( fontSize: 30, ) ) ); - return new Column( + return Column( children: questions ); } Widget getButtons(){ - List buttons = new List(); + List buttons = List(); 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 { title: Text("Practicing months"), ), body: Center( - child: new Container( + child: Container( padding: EdgeInsets.all(20), - child: new Column( + child: Column( children: [ - new Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - 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 { ), getQuestions(), getButtons(), - new Align( + Align( alignment: FractionalOffset.bottomCenter, child: getAnswerRow() ) @@ -215,7 +215,7 @@ class _MonthPracticeState extends State { _incorrect += 1; } _count += 1; - answers.add(new MonthPracticeAnswer(_month, answer)); + answers.add(MonthPracticeAnswer(_month, answer)); if((_startCount - _count) == 0) { Navigator.pop(context); return; diff --git a/lib/pages/practice/month/MonthPracticeSetupPage.dart b/lib/pages/practice/month/MonthPracticeSetupPage.dart index 4ec49ec..795c7f6 100644 --- a/lib/pages/practice/month/MonthPracticeSetupPage.dart +++ b/lib/pages/practice/month/MonthPracticeSetupPage.dart @@ -19,24 +19,24 @@ class _MonthPracticeSetupState extends State { title: Text("Practice Months"), ), body: Center( - child: new Container( + child: Container( padding: EdgeInsets.all(20), - child: new Column( + child: Column( children: [ - 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 { }); } ), - new SizedBox(height: 30), - new FlatButton( + SizedBox(height: 30), + FlatButton( onPressed: () { Navigator.pushNamed( context, @@ -53,7 +53,7 @@ class _MonthPracticeSetupState extends State { arguments: MonthPracticeSetup(_count, _showCorrect) ); }, - child: new Text("Start!"), + child: Text("Start!"), color: Colors.blue, textColor: Colors.white, padding: EdgeInsets.all(8.0) diff --git a/lib/util/Months.dart b/lib/util/Months.dart index 5e5d4c7..fcf9076 100644 --- a/lib/util/Months.dart +++ b/lib/util/Months.dart @@ -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;