Skip to content
Snippets Groups Projects
Commit 9ae9882e authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch '56-upgrade-flutter-framework-and-dependencies' into 'master'

Resolve "Upgrade Flutter framework and dependencies"

Closes #56

See merge request !59
parents b72989f1 1ecce966
No related branches found
No related tags found
1 merge request!59Resolve "Upgrade Flutter framework and dependencies"
Pipeline #2910 passed
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=0.1.25 app.versionName=0.1.26
app.versionCode=49 app.versionCode=50
...@@ -33,7 +33,6 @@ class MyApp extends StatelessWidget { ...@@ -33,7 +33,6 @@ class MyApp extends StatelessWidget {
builder: (context) => GamePickWordPage(), builder: (context) => GamePickWordPage(),
); );
} }
break;
case '/game-pick-image': case '/game-pick-image':
{ {
...@@ -41,7 +40,6 @@ class MyApp extends StatelessWidget { ...@@ -41,7 +40,6 @@ class MyApp extends StatelessWidget {
builder: (context) => GamePickImagePage(), builder: (context) => GamePickImagePage(),
); );
} }
break;
default: default:
{ {
......
...@@ -5,7 +5,7 @@ class Data extends ChangeNotifier { ...@@ -5,7 +5,7 @@ class Data extends ChangeNotifier {
String _lang = ''; String _lang = '';
// randomization // randomization
Map _word; Map _word = {};
List _otherWords = []; List _otherWords = [];
List _images = []; List _images = [];
final int _recentWordsCount = 20; final int _recentWordsCount = 20;
...@@ -27,7 +27,7 @@ class Data extends ChangeNotifier { ...@@ -27,7 +27,7 @@ class Data extends ChangeNotifier {
set updateWord(Map value) { set updateWord(Map value) {
_word = value; _word = value;
if (value != null && value['key'] != '') { if (value.containsKey('key') && value['key'] != '') {
_recentWords.insert(0, value['key']); _recentWords.insert(0, value['key']);
_recentWords = _recentWords.take(_recentWordsCount).toList(); _recentWords = _recentWords.take(_recentWordsCount).toList();
} }
...@@ -53,7 +53,7 @@ class Data extends ChangeNotifier { ...@@ -53,7 +53,7 @@ class Data extends ChangeNotifier {
} }
void resetGame() { void resetGame() {
_word = null; _word = {};
_otherWords = []; _otherWords = [];
_images = []; _images = [];
_questionsCount = 0; _questionsCount = 0;
......
...@@ -19,8 +19,8 @@ class GamePickImagePage extends StatelessWidget { ...@@ -19,8 +19,8 @@ class GamePickImagePage extends StatelessWidget {
myProvider.updateQuestionsCount = 0; myProvider.updateQuestionsCount = 0;
myProvider.updateGoodAnswers = 0; myProvider.updateGoodAnswers = 0;
myProvider.updateWrongAnswers = 0; myProvider.updateWrongAnswers = 0;
myProvider.updateWord = null; myProvider.updateWord = {};
myProvider.updateImages = null; myProvider.updateImages = [];
} }
Future<void> nextWord(Data myProvider) async { Future<void> nextWord(Data myProvider) async {
...@@ -29,24 +29,22 @@ class GamePickImagePage extends StatelessWidget { ...@@ -29,24 +29,22 @@ class GamePickImagePage extends StatelessWidget {
} }
Future<void> pickData(Data myProvider) async { Future<void> pickData(Data myProvider) async {
List words; List words = [];
RandomPickData randomPickData; RandomPickData randomPickData;
Map word; Map word = {};
int attempts = 0; int attempts = 0;
do { do {
randomPickData = RandomPickData(); randomPickData = RandomPickData();
await randomPickData.init(myProvider.lang, _countWords, _countImages); await randomPickData.init(myProvider.lang, _countWords, _countImages);
if (randomPickData.words != null) { if (randomPickData.words.isNotEmpty) {
words = randomPickData.words; words = randomPickData.words;
word = words.take(1).toList()[0]; word = words.take(1).toList()[0];
} }
attempts++; attempts++;
if ((words != null) && if ((words.length == _countWords) && !myProvider.isRecentlyPicked(word['key'])) {
(words.length == _countWords) &&
!myProvider.isRecentlyPicked(word['key'])) {
myProvider.updateWord = word; myProvider.updateWord = word;
myProvider.updateImages = words; myProvider.updateImages = words;
} }
...@@ -140,7 +138,7 @@ class GamePickImagePage extends StatelessWidget { ...@@ -140,7 +138,7 @@ class GamePickImagePage extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
border: Border.all( border: Border.all(
color: Colors.blue[200], color: Colors.blue.shade200,
width: 8, width: 8,
), ),
), ),
...@@ -162,7 +160,7 @@ class GamePickImagePage extends StatelessWidget { ...@@ -162,7 +160,7 @@ class GamePickImagePage extends StatelessWidget {
Column _buildImageItemsBlock(Data myProvider) { Column _buildImageItemsBlock(Data myProvider) {
List words = myProvider.images; List words = myProvider.images;
if ((words == null) || (words.length != _countWords)) { if (words.length != _countWords) {
return Column(); return Column();
} }
...@@ -195,7 +193,7 @@ class GamePickImagePage extends StatelessWidget { ...@@ -195,7 +193,7 @@ class GamePickImagePage extends StatelessWidget {
Column _buildTextItemBlock(Data myProvider) { Column _buildTextItemBlock(Data myProvider) {
Map word = myProvider.word; Map word = myProvider.word;
if (word == null) { if (word.isEmpty) {
return Column(); return Column();
} }
...@@ -218,7 +216,7 @@ class GamePickImagePage extends StatelessWidget { ...@@ -218,7 +216,7 @@ class GamePickImagePage extends StatelessWidget {
padding: EdgeInsets.all(15), padding: EdgeInsets.all(15),
), ),
child: Text( child: Text(
word != null ? word[myProvider.lang] : '', word.containsKey(myProvider.lang) ? word[myProvider.lang] : '',
style: TextStyle( style: TextStyle(
fontSize: 30, fontSize: 30,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
...@@ -299,7 +297,7 @@ class GamePickImagePage extends StatelessWidget { ...@@ -299,7 +297,7 @@ class GamePickImagePage extends StatelessWidget {
children: <Widget>[ children: <Widget>[
_buildTextItemBlock(_myProvider), _buildTextItemBlock(_myProvider),
SizedBox(height: 2), SizedBox(height: 2),
((_myProvider.word == null) || (_myProvider.word['key'] == '')) ((!_myProvider.word.containsKey('key')) || (_myProvider.word['key'] == ''))
? _buildStartGameBlock(_myProvider) ? _buildStartGameBlock(_myProvider)
: _buildScoreContainer(_myProvider), : _buildScoreContainer(_myProvider),
SizedBox(height: 2), SizedBox(height: 2),
......
...@@ -19,8 +19,8 @@ class GamePickWordPage extends StatelessWidget { ...@@ -19,8 +19,8 @@ class GamePickWordPage extends StatelessWidget {
myProvider.updateQuestionsCount = 0; myProvider.updateQuestionsCount = 0;
myProvider.updateGoodAnswers = 0; myProvider.updateGoodAnswers = 0;
myProvider.updateWrongAnswers = 0; myProvider.updateWrongAnswers = 0;
myProvider.updateWord = null; myProvider.updateWord = {};
myProvider.updateImages = null; myProvider.updateImages = [];
} }
Future<void> nextWord(Data myProvider) async { Future<void> nextWord(Data myProvider) async {
...@@ -29,25 +29,25 @@ class GamePickWordPage extends StatelessWidget { ...@@ -29,25 +29,25 @@ class GamePickWordPage extends StatelessWidget {
} }
Future<void> pickData(Data myProvider) async { Future<void> pickData(Data myProvider) async {
List words; List words = [];
List images; List images = [];
RandomPickData randomPickData; RandomPickData randomPickData;
Map word; Map word = {};
int attempts = 0; int attempts = 0;
do { do {
randomPickData = RandomPickData(); randomPickData = RandomPickData();
await randomPickData.init(myProvider.lang, _countWords, _countImages); await randomPickData.init(myProvider.lang, _countWords, _countImages);
if (randomPickData.words != null) { if (randomPickData.words.isNotEmpty) {
words = randomPickData.words; words = randomPickData.words;
word = words.take(1).toList()[0]; word = words.take(1).toList()[0];
images = word['images']; images = word['images'];
} }
attempts++; attempts++;
if (((words != null) && (words.length == _countWords)) && if ((words.length == _countWords) &&
((images != null) && (images.length == _countImages)) && (images.length == _countImages) &&
!myProvider.isRecentlyPicked(word['key'])) { !myProvider.isRecentlyPicked(word['key'])) {
myProvider.updateWord = word; myProvider.updateWord = word;
myProvider.updateOtherWords = words.skip(1).toList(); myProvider.updateOtherWords = words.skip(1).toList();
...@@ -131,7 +131,7 @@ class GamePickWordPage extends StatelessWidget { ...@@ -131,7 +131,7 @@ class GamePickWordPage extends StatelessWidget {
double imageSize = 130; double imageSize = 130;
String imageAsset = 'assets/placeholder.png'; String imageAsset = 'assets/placeholder.png';
if (image != null) { if (image != '') {
imageAsset = 'assets/images/' + image; imageAsset = 'assets/images/' + image;
} }
...@@ -140,7 +140,7 @@ class GamePickWordPage extends StatelessWidget { ...@@ -140,7 +140,7 @@ class GamePickWordPage extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
border: Border.all( border: Border.all(
color: Colors.blue[200], color: Colors.blue.shade200,
width: 8, width: 8,
), ),
), ),
...@@ -153,7 +153,7 @@ class GamePickWordPage extends StatelessWidget { ...@@ -153,7 +153,7 @@ class GamePickWordPage extends StatelessWidget {
} }
Column _buildImageItemsBlock(List images) { Column _buildImageItemsBlock(List images) {
if ((images == null) || (images.length != _countImages)) { if (images.length != _countImages) {
return Column(); return Column();
} }
...@@ -197,7 +197,7 @@ class GamePickWordPage extends StatelessWidget { ...@@ -197,7 +197,7 @@ class GamePickWordPage extends StatelessWidget {
padding: EdgeInsets.all(15), padding: EdgeInsets.all(15),
), ),
child: Text( child: Text(
word != null ? word[myProvider.lang] : '', word.containsKey(myProvider.lang) ? word[myProvider.lang] : '',
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
...@@ -215,7 +215,7 @@ class GamePickWordPage extends StatelessWidget { ...@@ -215,7 +215,7 @@ class GamePickWordPage extends StatelessWidget {
Map word = myProvider.word; Map word = myProvider.word;
List otherWords = myProvider.otherWords; List otherWords = myProvider.otherWords;
if ((word == null) || (otherWords.length != (_countWords - 1))) { if ((word.isEmpty) || (otherWords.length != (_countWords - 1))) {
return Column(); return Column();
} }
...@@ -322,7 +322,7 @@ class GamePickWordPage extends StatelessWidget { ...@@ -322,7 +322,7 @@ class GamePickWordPage extends StatelessWidget {
children: <Widget>[ children: <Widget>[
_buildImageItemsBlock(_myProvider.images), _buildImageItemsBlock(_myProvider.images),
SizedBox(height: 2), SizedBox(height: 2),
((_myProvider.word == null) || (_myProvider.word['key'] == '')) ((!_myProvider.word.containsKey('key')) || (_myProvider.word['key'] == ''))
? _buildStartGameBlock(_myProvider) ? _buildStartGameBlock(_myProvider)
: _buildScoreContainer(_myProvider), : _buildScoreContainer(_myProvider),
SizedBox(height: 2), SizedBox(height: 2),
......
...@@ -11,9 +11,9 @@ class Home extends StatelessWidget { ...@@ -11,9 +11,9 @@ class Home extends StatelessWidget {
myProvider.updateQuestionsCount = 0; myProvider.updateQuestionsCount = 0;
myProvider.updateGoodAnswers = 0; myProvider.updateGoodAnswers = 0;
myProvider.updateWrongAnswers = 0; myProvider.updateWrongAnswers = 0;
myProvider.updateWord = null; myProvider.updateWord = {};
myProvider.updateOtherWords = null; myProvider.updateOtherWords = [];
myProvider.updateImages = null; myProvider.updateImages = [];
} }
@override @override
......
...@@ -6,7 +6,7 @@ import 'random_pick_image.dart'; ...@@ -6,7 +6,7 @@ import 'random_pick_image.dart';
class RandomPickData { class RandomPickData {
RandomPickData(); RandomPickData();
List _words; List _words = [];
init(String lang, int wordsCount, int imagesPerWordCount) async { init(String lang, int wordsCount, int imagesPerWordCount) async {
_words = List.filled(wordsCount, []); _words = List.filled(wordsCount, []);
...@@ -18,12 +18,12 @@ class RandomPickData { ...@@ -18,12 +18,12 @@ class RandomPickData {
RandomPickWord randomPickWord; RandomPickWord randomPickWord;
RandomPickImage randomPickImage; RandomPickImage randomPickImage;
List pickedWords; List pickedWords = [];
randomPickWord = RandomPickWord(); randomPickWord = RandomPickWord();
await randomPickWord.init(lang, wordsCount); await randomPickWord.init(lang, wordsCount);
if (randomPickWord.words != null) { if (randomPickWord.words.isNotEmpty) {
pickedWords = randomPickWord.words; pickedWords = randomPickWord.words;
for (var i = 0; i < pickedWords.length; i++) { for (var i = 0; i < pickedWords.length; i++) {
...@@ -31,7 +31,7 @@ class RandomPickData { ...@@ -31,7 +31,7 @@ class RandomPickData {
randomPickImage = RandomPickImage(); randomPickImage = RandomPickImage();
await randomPickImage.init(word['key'], imagesPerWordCount); await randomPickImage.init(word['key'], imagesPerWordCount);
if (randomPickImage.images != null) { if (randomPickImage.images.isNotEmpty) {
pickedWords[i]['images'] = randomPickImage.images; pickedWords[i]['images'] = randomPickImage.images;
} }
} }
......
...@@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; ...@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
class RandomPickImage { class RandomPickImage {
RandomPickImage(); RandomPickImage();
List _images; List _images = [];
init(String word, int count) async { init(String word, int count) async {
_images = List.filled(count, []); _images = List.filled(count, []);
...@@ -14,7 +14,8 @@ class RandomPickImage { ...@@ -14,7 +14,8 @@ class RandomPickImage {
Future<void> imageFromLocalFile(String word, int count) async { Future<void> imageFromLocalFile(String word, int count) async {
// Get all images for this word // Get all images for this word
List imageList; List imageList = [];
try { try {
String jsonString = await rootBundle.loadString('assets/assets_images.json'); String jsonString = await rootBundle.loadString('assets/assets_images.json');
final jsonResponse = await json.decode(jsonString); final jsonResponse = await json.decode(jsonString);
...@@ -24,7 +25,7 @@ class RandomPickImage { ...@@ -24,7 +25,7 @@ class RandomPickImage {
} }
// Check we have enough images // Check we have enough images
if ((imageList == null) || (imageList.length < count)) { if (imageList.length < count) {
print('Not enough images in list for word "' + word + '".'); print('Not enough images in list for word "' + word + '".');
_images = []; _images = [];
} else { } else {
......
...@@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; ...@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
class RandomPickWord { class RandomPickWord {
RandomPickWord(); RandomPickWord();
List _words; List _words = [];
init(String lang, int count) async { init(String lang, int count) async {
_words = List.filled(count, []); _words = List.filled(count, []);
...@@ -14,7 +14,8 @@ class RandomPickWord { ...@@ -14,7 +14,8 @@ class RandomPickWord {
Future<void> wordFromLocalFile(String lang, int count) async { Future<void> wordFromLocalFile(String lang, int count) async {
// Get global words list // Get global words list
List wordList; List wordList = [];
try { try {
String jsonString = await rootBundle.loadString('assets/files/words.json'); String jsonString = await rootBundle.loadString('assets/files/words.json');
final jsonResponse = await json.decode(jsonString); final jsonResponse = await json.decode(jsonString);
......
...@@ -73,7 +73,7 @@ packages: ...@@ -73,7 +73,7 @@ packages:
name: http_parser name: http_parser
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
...@@ -115,7 +115,7 @@ packages: ...@@ -115,7 +115,7 @@ packages:
name: provider name: provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.2" version: "6.0.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -169,7 +169,7 @@ packages: ...@@ -169,7 +169,7 @@ packages:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.1"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
......
...@@ -4,7 +4,7 @@ publish_to: 'none' ...@@ -4,7 +4,7 @@ publish_to: 'none'
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.16.1 <3.0.0"
dependencies: dependencies:
flutter: flutter:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment