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

Setup words list

parent d0f46a0e
No related branches found
No related tags found
1 merge request!5Resolve "Setup words list"
Pipeline #931 passed
{
"words": [
"ANACONDA",
"AUTRUCHE",
"BARRACUDA",
"BOUQUETIN",
"COCCINELLE",
"CROCODILE",
"DROMADAIRE",
"ELEPHANT",
"ESCARGOT",
"FOURMILIER",
"GRENOUILLE",
"HIPPOCAMPE",
"HIPPOPOTAME",
"KANGOUROU",
"LIBELLULE",
"PERROQUET",
"PIPISTRELLE",
"RHINOCEROS",
"SAUTERELLE",
"TARENTULE",
"AUBERGINE",
"BETTERAVE",
"CITROUILLE",
"CONCOMBRE",
"FRAMBOISE",
"GROSEILLE",
"MANDARINE",
"MIRABELLE",
"MYRTILLE",
"PAMPLEMOUSSE",
"ROUGE",
"BLEU",
"VERT",
"JAUNE",
"VIOLET",
"ORANGE",
"MARRON",
"NOIR",
"BLANC",
"TURQUOISE",
"BEIGE",
"ROSE",
"PIVOINE",
"TULIPE",
"JONQUILLE",
"CACTUS",
"GYMNASTIQUE",
"FOOTBALL",
"HANDBALL",
"COURSE",
"CYCLISME",
"RANDONNEE",
"FROMAGE",
"PIZZA",
"SAUCISSON",
"JAMBON",
"SALAMI",
"PAELLA",
"PATES",
"SALADE",
"SOUPE",
"CHOCOLAT",
"OEUF",
"CREME",
"LAIT",
"CORNICHON",
"FLAN",
"TARTE",
"PUREE",
"SAUMON",
"SANDWICH",
"VOITURE",
"MOTO",
"VELO",
"TRAIN",
"BATEAU",
"AVION",
"HELICOPTERE",
"AUTOBUS",
"CAR",
"TRAINEAU",
"FUSEE",
"VOILIER",
"PAQUEBOT",
"METRO",
"SOUS-MARIN",
"CAMION",
"TRACTEUR",
"KAYAK"
]
}
import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'dart:math' show Random;
class RandomPickWord {
RandomPickWord();
String _word;
final random = Random();
init() async {
await wordFromLocalFile();
}
Future<void> wordFromLocalFile() async {
String jsonString;
try {
jsonString = await rootBundle.loadString('assets/files/words-fr.json');
final jsonResponse = await json.decode(jsonString);
var wordList = jsonResponse[jsonResponse.keys.toList().join()];
int randomWordIndex = random.nextInt(wordList.length);
String word = wordList[random.nextInt(wordList.length)];
_word = word ?? 'UNEXPECTED ERROR';
} catch (e) {
_word = 'UNEXPECTED ERROR';
}
}
String get word => _word;
}
...@@ -17,3 +17,5 @@ dev_dependencies: ...@@ -17,3 +17,5 @@ dev_dependencies:
flutter: flutter:
uses-material-design: true uses-material-design: true
assets:
- assets/files/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment