@@ -21,7 +21,7 @@ void main() {
2121}
2222
2323class MyApp extends StatelessWidget {
24- const MyApp ({Key key}) : super (key: key);
24+ const MyApp ({Key ? key}) : super (key: key);
2525
2626 static const String versionNumber = '2.4.1' ;
2727
@@ -39,7 +39,7 @@ class MyApp extends StatelessWidget {
3939}
4040
4141class HomePage extends StatefulWidget {
42- const HomePage ({Key key}) : super (key: key);
42+ const HomePage ({Key ? key}) : super (key: key);
4343
4444 @override
4545 State <StatefulWidget > createState () => HomePageState ();
@@ -50,13 +50,13 @@ class HomePageState extends State<HomePage> {
5050 bool gameOver = false ;
5151 int timesCalled = 0 ;
5252 bool isButtonDisabled = false ;
53- List <List <List <int >>> gameList;
54- List <List <int >> game;
55- List <List <int >> gameCopy;
56- List <List <int >> gameSolved;
57- static String currentDifficultyLevel;
58- static String currentTheme;
59- static String currentAccentColor;
53+ late List <List <List <int >>> gameList;
54+ late List <List <int >> game;
55+ late List <List <int >> gameCopy;
56+ late List <List <int >> gameSolved;
57+ static String ? currentDifficultyLevel;
58+ static String ? currentTheme;
59+ static String ? currentAccentColor;
6060 static String platform = () {
6161 if (kIsWeb) {
6262 return 'web-${defaultTargetPlatform .toString ().replaceFirst ("TargetPlatform." , "" ).toLowerCase ()}' ;
@@ -99,9 +99,9 @@ class HomePageState extends State<HomePage> {
9999 currentAccentColor = 'Blue' ;
100100 setPrefs ('currentAccentColor' );
101101 }
102- newGame (currentDifficultyLevel);
102+ newGame (currentDifficultyLevel! );
103103 changeTheme ('set' );
104- changeAccentColor (currentAccentColor, true );
104+ changeAccentColor (currentAccentColor! , true );
105105 });
106106 }
107107
@@ -117,11 +117,11 @@ class HomePageState extends State<HomePage> {
117117 setPrefs (String property) async {
118118 final prefs = await SharedPreferences .getInstance ();
119119 if (property == 'currentDifficultyLevel' ) {
120- prefs.setString ('currentDifficultyLevel' , currentDifficultyLevel);
120+ prefs.setString ('currentDifficultyLevel' , currentDifficultyLevel! );
121121 } else if (property == 'currentTheme' ) {
122- prefs.setString ('currentTheme' , currentTheme);
122+ prefs.setString ('currentTheme' , currentTheme! );
123123 } else if (property == 'currentAccentColor' ) {
124- prefs.setString ('currentAccentColor' , currentAccentColor);
124+ prefs.setString ('currentAccentColor' , currentAccentColor! );
125125 }
126126 }
127127
@@ -157,10 +157,10 @@ class HomePageState extends State<HomePage> {
157157 void changeAccentColor (String color, [bool firstRun = false ]) {
158158 setState (() {
159159 if (Styles .accentColors.keys.contains (color)) {
160- Styles .primaryColor = Styles .accentColors[color];
160+ Styles .primaryColor = Styles .accentColors[color]! ;
161161 } else {
162162 currentAccentColor = 'Blue' ;
163- Styles .primaryColor = Styles .accentColors[color];
163+ Styles .primaryColor = Styles .accentColors[color]! ;
164164 }
165165 if (color == 'Red' ) {
166166 Styles .secondaryColor = Styles .orange;
@@ -228,6 +228,11 @@ class HomePageState extends State<HomePage> {
228228 emptySquares = 54 ;
229229 }
230230 break ;
231+ default :
232+ {
233+ emptySquares = 2 ;
234+ }
235+ break ;
231236 }
232237 SudokuGenerator generator = SudokuGenerator (emptySquares: emptySquares);
233238 return [generator.newSudoku, generator.newSudokuSolved];
@@ -281,7 +286,7 @@ class HomePageState extends State<HomePage> {
281286 if (Styles .primaryBackgroundColor == Styles .darkGrey) {
282287 color = Styles .grey;
283288 } else {
284- color = Colors .grey[300 ];
289+ color = Colors .grey[300 ]! ;
285290 }
286291 } else {
287292 color = Styles .primaryBackgroundColor;
@@ -332,7 +337,7 @@ class HomePageState extends State<HomePage> {
332337 } else {
333338 emptyColor = Styles .secondaryColor;
334339 }
335- List <SizedBox > buttonList = List <SizedBox >.filled (9 , null );
340+ List <SizedBox > buttonList = List <SizedBox >.filled (9 , const SizedBox () );
336341 for (var i = 0 ; i <= 8 ; i++ ) {
337342 var k = timesCalled;
338343 buttonList[i] = SizedBox (
@@ -403,14 +408,11 @@ class HomePageState extends State<HomePage> {
403408 }
404409
405410 List <Row > createRows () {
406- List <Row > rowList = List <Row >.filled (9 , null );
407- for (var i = 0 ; i <= 8 ; i++ ) {
408- rowList[i] = oneRow ();
409- }
411+ List <Row > rowList = List <Row >.generate (9 , (i) => oneRow ());
410412 return rowList;
411413 }
412414
413- void callback (List <int > index, int number) {
415+ void callback (List <int > index, int ? number) {
414416 setState (() {
415417 if (number == null ) {
416418 return ;
@@ -453,7 +455,7 @@ class HomePageState extends State<HomePage> {
453455 onTap: () {
454456 Navigator .pop (context);
455457 Timer (const Duration (milliseconds: 200 ),
456- () => newGame (currentDifficultyLevel));
458+ () => newGame (currentDifficultyLevel! ));
457459 },
458460 ),
459461 ListTile (
@@ -480,7 +482,7 @@ class HomePageState extends State<HomePage> {
480482 duration: const Duration (milliseconds: 350 ),
481483 context: outerContext,
482484 builder: (_) => AlertDifficultyState (
483- currentDifficultyLevel)).whenComplete (() {
485+ currentDifficultyLevel! )).whenComplete (() {
484486 if (AlertDifficultyState .difficulty != null ) {
485487 Timer (const Duration (milliseconds: 300 ), () {
486488 newGame (
@@ -519,7 +521,7 @@ class HomePageState extends State<HomePage> {
519521 duration: const Duration (milliseconds: 350 ),
520522 context: outerContext,
521523 builder: (_) => AlertAccentColorsState (
522- currentAccentColor)).whenComplete (() {
524+ currentAccentColor! )).whenComplete (() {
523525 if (AlertAccentColorsState .accentColor != null ) {
524526 Timer (const Duration (milliseconds: 300 ), () {
525527 currentAccentColor =
0 commit comments