From 1ecce966ae3d5070d78e0853d74760ac21aa2d33 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Thu, 23 Jun 2022 13:23:50 +0200
Subject: [PATCH] Upgrade Flutter framework and dependencies

---
 android/gradle.properties        |  4 ++--
 lib/main.dart                    |  2 --
 lib/provider/data.dart           |  6 +++---
 lib/screens/game_pick_image.dart | 24 +++++++++++-------------
 lib/screens/game_pick_word.dart  | 28 ++++++++++++++--------------
 lib/screens/home.dart            |  6 +++---
 lib/utils/random_pick_data.dart  |  8 ++++----
 lib/utils/random_pick_image.dart |  7 ++++---
 lib/utils/random_pick_word.dart  |  5 +++--
 pubspec.lock                     |  6 +++---
 pubspec.yaml                     |  2 +-
 11 files changed, 48 insertions(+), 50 deletions(-)

diff --git a/android/gradle.properties b/android/gradle.properties
index 3e5bc11..d2167ba 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -1,5 +1,5 @@
 org.gradle.jvmargs=-Xmx1536M
 android.useAndroidX=true
 android.enableJetifier=true
-app.versionName=0.1.25
-app.versionCode=49
+app.versionName=0.1.26
+app.versionCode=50
diff --git a/lib/main.dart b/lib/main.dart
index 60bfe3f..8f745e2 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -33,7 +33,6 @@ class MyApp extends StatelessWidget {
                     builder: (context) => GamePickWordPage(),
                   );
                 }
-                break;
 
               case '/game-pick-image':
                 {
@@ -41,7 +40,6 @@ class MyApp extends StatelessWidget {
                     builder: (context) => GamePickImagePage(),
                   );
                 }
-                break;
 
               default:
                 {
diff --git a/lib/provider/data.dart b/lib/provider/data.dart
index 42c833c..841c3a6 100644
--- a/lib/provider/data.dart
+++ b/lib/provider/data.dart
@@ -5,7 +5,7 @@ class Data extends ChangeNotifier {
   String _lang = '';
 
   // randomization
-  Map _word;
+  Map _word = {};
   List _otherWords = [];
   List _images = [];
   final int _recentWordsCount = 20;
@@ -27,7 +27,7 @@ class Data extends ChangeNotifier {
 
   set updateWord(Map value) {
     _word = value;
-    if (value != null && value['key'] != '') {
+    if (value.containsKey('key') && value['key'] != '') {
       _recentWords.insert(0, value['key']);
       _recentWords = _recentWords.take(_recentWordsCount).toList();
     }
@@ -53,7 +53,7 @@ class Data extends ChangeNotifier {
   }
 
   void resetGame() {
-    _word = null;
+    _word = {};
     _otherWords = [];
     _images = [];
     _questionsCount = 0;
diff --git a/lib/screens/game_pick_image.dart b/lib/screens/game_pick_image.dart
index bf549de..c7d7d3d 100644
--- a/lib/screens/game_pick_image.dart
+++ b/lib/screens/game_pick_image.dart
@@ -19,8 +19,8 @@ class GamePickImagePage extends StatelessWidget {
     myProvider.updateQuestionsCount = 0;
     myProvider.updateGoodAnswers = 0;
     myProvider.updateWrongAnswers = 0;
-    myProvider.updateWord = null;
-    myProvider.updateImages = null;
+    myProvider.updateWord = {};
+    myProvider.updateImages = [];
   }
 
   Future<void> nextWord(Data myProvider) async {
@@ -29,24 +29,22 @@ class GamePickImagePage extends StatelessWidget {
   }
 
   Future<void> pickData(Data myProvider) async {
-    List words;
+    List words = [];
     RandomPickData randomPickData;
-    Map word;
+    Map word = {};
 
     int attempts = 0;
     do {
       randomPickData = RandomPickData();
       await randomPickData.init(myProvider.lang, _countWords, _countImages);
 
-      if (randomPickData.words != null) {
+      if (randomPickData.words.isNotEmpty) {
         words = randomPickData.words;
         word = words.take(1).toList()[0];
       }
       attempts++;
 
-      if ((words != null) &&
-          (words.length == _countWords) &&
-          !myProvider.isRecentlyPicked(word['key'])) {
+      if ((words.length == _countWords) && !myProvider.isRecentlyPicked(word['key'])) {
         myProvider.updateWord = word;
         myProvider.updateImages = words;
       }
@@ -140,7 +138,7 @@ class GamePickImagePage extends StatelessWidget {
           decoration: BoxDecoration(
             borderRadius: BorderRadius.circular(8),
             border: Border.all(
-              color: Colors.blue[200],
+              color: Colors.blue.shade200,
               width: 8,
             ),
           ),
@@ -162,7 +160,7 @@ class GamePickImagePage extends StatelessWidget {
   Column _buildImageItemsBlock(Data myProvider) {
     List words = myProvider.images;
 
-    if ((words == null) || (words.length != _countWords)) {
+    if (words.length != _countWords) {
       return Column();
     }
 
@@ -195,7 +193,7 @@ class GamePickImagePage extends StatelessWidget {
   Column _buildTextItemBlock(Data myProvider) {
     Map word = myProvider.word;
 
-    if (word == null) {
+    if (word.isEmpty) {
       return Column();
     }
 
@@ -218,7 +216,7 @@ class GamePickImagePage extends StatelessWidget {
               padding: EdgeInsets.all(15),
             ),
             child: Text(
-              word != null ? word[myProvider.lang] : '',
+              word.containsKey(myProvider.lang) ? word[myProvider.lang] : '',
               style: TextStyle(
                 fontSize: 30,
                 fontWeight: FontWeight.w600,
@@ -299,7 +297,7 @@ class GamePickImagePage extends StatelessWidget {
           children: <Widget>[
             _buildTextItemBlock(_myProvider),
             SizedBox(height: 2),
-            ((_myProvider.word == null) || (_myProvider.word['key'] == ''))
+            ((!_myProvider.word.containsKey('key')) || (_myProvider.word['key'] == ''))
                 ? _buildStartGameBlock(_myProvider)
                 : _buildScoreContainer(_myProvider),
             SizedBox(height: 2),
diff --git a/lib/screens/game_pick_word.dart b/lib/screens/game_pick_word.dart
index 9b1aa62..df675f8 100644
--- a/lib/screens/game_pick_word.dart
+++ b/lib/screens/game_pick_word.dart
@@ -19,8 +19,8 @@ class GamePickWordPage extends StatelessWidget {
     myProvider.updateQuestionsCount = 0;
     myProvider.updateGoodAnswers = 0;
     myProvider.updateWrongAnswers = 0;
-    myProvider.updateWord = null;
-    myProvider.updateImages = null;
+    myProvider.updateWord = {};
+    myProvider.updateImages = [];
   }
 
   Future<void> nextWord(Data myProvider) async {
@@ -29,25 +29,25 @@ class GamePickWordPage extends StatelessWidget {
   }
 
   Future<void> pickData(Data myProvider) async {
-    List words;
-    List images;
+    List words = [];
+    List images = [];
     RandomPickData randomPickData;
-    Map word;
+    Map word = {};
 
     int attempts = 0;
     do {
       randomPickData = RandomPickData();
       await randomPickData.init(myProvider.lang, _countWords, _countImages);
 
-      if (randomPickData.words != null) {
+      if (randomPickData.words.isNotEmpty) {
         words = randomPickData.words;
         word = words.take(1).toList()[0];
         images = word['images'];
       }
       attempts++;
 
-      if (((words != null) && (words.length == _countWords)) &&
-          ((images != null) && (images.length == _countImages)) &&
+      if ((words.length == _countWords) &&
+          (images.length == _countImages) &&
           !myProvider.isRecentlyPicked(word['key'])) {
         myProvider.updateWord = word;
         myProvider.updateOtherWords = words.skip(1).toList();
@@ -131,7 +131,7 @@ class GamePickWordPage extends StatelessWidget {
     double imageSize = 130;
 
     String imageAsset = 'assets/placeholder.png';
-    if (image != null) {
+    if (image != '') {
       imageAsset = 'assets/images/' + image;
     }
 
@@ -140,7 +140,7 @@ class GamePickWordPage extends StatelessWidget {
       decoration: BoxDecoration(
         borderRadius: BorderRadius.circular(8),
         border: Border.all(
-          color: Colors.blue[200],
+          color: Colors.blue.shade200,
           width: 8,
         ),
       ),
@@ -153,7 +153,7 @@ class GamePickWordPage extends StatelessWidget {
   }
 
   Column _buildImageItemsBlock(List images) {
-    if ((images == null) || (images.length != _countImages)) {
+    if (images.length != _countImages) {
       return Column();
     }
 
@@ -197,7 +197,7 @@ class GamePickWordPage extends StatelessWidget {
           padding: EdgeInsets.all(15),
         ),
         child: Text(
-          word != null ? word[myProvider.lang] : '',
+          word.containsKey(myProvider.lang) ? word[myProvider.lang] : '',
           style: TextStyle(
             fontSize: 20,
             fontWeight: FontWeight.w600,
@@ -215,7 +215,7 @@ class GamePickWordPage extends StatelessWidget {
     Map word = myProvider.word;
     List otherWords = myProvider.otherWords;
 
-    if ((word == null) || (otherWords.length != (_countWords - 1))) {
+    if ((word.isEmpty) || (otherWords.length != (_countWords - 1))) {
       return Column();
     }
 
@@ -322,7 +322,7 @@ class GamePickWordPage extends StatelessWidget {
           children: <Widget>[
             _buildImageItemsBlock(_myProvider.images),
             SizedBox(height: 2),
-            ((_myProvider.word == null) || (_myProvider.word['key'] == ''))
+            ((!_myProvider.word.containsKey('key')) || (_myProvider.word['key'] == ''))
                 ? _buildStartGameBlock(_myProvider)
                 : _buildScoreContainer(_myProvider),
             SizedBox(height: 2),
diff --git a/lib/screens/home.dart b/lib/screens/home.dart
index bfe6a84..76cc8ad 100644
--- a/lib/screens/home.dart
+++ b/lib/screens/home.dart
@@ -11,9 +11,9 @@ class Home extends StatelessWidget {
     myProvider.updateQuestionsCount = 0;
     myProvider.updateGoodAnswers = 0;
     myProvider.updateWrongAnswers = 0;
-    myProvider.updateWord = null;
-    myProvider.updateOtherWords = null;
-    myProvider.updateImages = null;
+    myProvider.updateWord = {};
+    myProvider.updateOtherWords = [];
+    myProvider.updateImages = [];
   }
 
   @override
diff --git a/lib/utils/random_pick_data.dart b/lib/utils/random_pick_data.dart
index 9a21081..3875f18 100644
--- a/lib/utils/random_pick_data.dart
+++ b/lib/utils/random_pick_data.dart
@@ -6,7 +6,7 @@ import 'random_pick_image.dart';
 class RandomPickData {
   RandomPickData();
 
-  List _words;
+  List _words = [];
 
   init(String lang, int wordsCount, int imagesPerWordCount) async {
     _words = List.filled(wordsCount, []);
@@ -18,12 +18,12 @@ class RandomPickData {
     RandomPickWord randomPickWord;
     RandomPickImage randomPickImage;
 
-    List pickedWords;
+    List pickedWords = [];
 
     randomPickWord = RandomPickWord();
     await randomPickWord.init(lang, wordsCount);
 
-    if (randomPickWord.words != null) {
+    if (randomPickWord.words.isNotEmpty) {
       pickedWords = randomPickWord.words;
 
       for (var i = 0; i < pickedWords.length; i++) {
@@ -31,7 +31,7 @@ class RandomPickData {
 
         randomPickImage = RandomPickImage();
         await randomPickImage.init(word['key'], imagesPerWordCount);
-        if (randomPickImage.images != null) {
+        if (randomPickImage.images.isNotEmpty) {
           pickedWords[i]['images'] = randomPickImage.images;
         }
       }
diff --git a/lib/utils/random_pick_image.dart b/lib/utils/random_pick_image.dart
index a726960..cc156d1 100644
--- a/lib/utils/random_pick_image.dart
+++ b/lib/utils/random_pick_image.dart
@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
 class RandomPickImage {
   RandomPickImage();
 
-  List _images;
+  List _images = [];
 
   init(String word, int count) async {
     _images = List.filled(count, []);
@@ -14,7 +14,8 @@ class RandomPickImage {
 
   Future<void> imageFromLocalFile(String word, int count) async {
     // Get all images for this word
-    List imageList;
+    List imageList = [];
+
     try {
       String jsonString = await rootBundle.loadString('assets/assets_images.json');
       final jsonResponse = await json.decode(jsonString);
@@ -24,7 +25,7 @@ class RandomPickImage {
     }
 
     // Check we have enough images
-    if ((imageList == null) || (imageList.length < count)) {
+    if (imageList.length < count) {
       print('Not enough images in list for word "' + word + '".');
       _images = [];
     } else {
diff --git a/lib/utils/random_pick_word.dart b/lib/utils/random_pick_word.dart
index eb4cfbc..4300e7e 100644
--- a/lib/utils/random_pick_word.dart
+++ b/lib/utils/random_pick_word.dart
@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
 class RandomPickWord {
   RandomPickWord();
 
-  List _words;
+  List _words = [];
 
   init(String lang, int count) async {
     _words = List.filled(count, []);
@@ -14,7 +14,8 @@ class RandomPickWord {
 
   Future<void> wordFromLocalFile(String lang, int count) async {
     // Get global words list
-    List wordList;
+    List wordList = [];
+
     try {
       String jsonString = await rootBundle.loadString('assets/files/words.json');
       final jsonResponse = await json.decode(jsonString);
diff --git a/pubspec.lock b/pubspec.lock
index 15e5564..5a0caee 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -73,7 +73,7 @@ packages:
       name: http_parser
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "4.0.0"
+    version: "4.0.1"
   matcher:
     dependency: transitive
     description:
@@ -115,7 +115,7 @@ packages:
       name: provider
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "6.0.2"
+    version: "6.0.3"
   sky_engine:
     dependency: transitive
     description: flutter
@@ -169,7 +169,7 @@ packages:
       name: typed_data
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.3.0"
+    version: "1.3.1"
   vector_math:
     dependency: transitive
     description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 6d45b4d..ebed783 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -4,7 +4,7 @@ publish_to: 'none'
 version: 1.0.0+1
 
 environment:
-  sdk: ">=2.7.0 <3.0.0"
+  sdk: ">=2.16.1 <3.0.0"
 
 dependencies:
   flutter:
-- 
GitLab