11// These aren't necessary for standard operation of the API;
22// they are only required for the API key import and some of the example code
33import 'dart:math' ;
4- import 'package:credentials/credentials .dart' ;
4+ import 'package:credentials_helper/credentials_helper .dart' ;
55
66// Required imports
77import 'package:wordnik/wordnik.dart' ;
88
99void main () async {
10+ Random random = Random ();
11+
1012 // This isn't required, but you'll need to provide the API key in some way
1113 Credentials credentials = Credentials .fromFile ('credentials.json' );
1214
@@ -42,7 +44,7 @@ void main() async {
4244 print ('The first one is: "${examples .examples .first .text }"\n ' );
4345
4446 FrequencySummary frequencySummary = await wordnik.getWordFrequency (exampleWord.word);
45- Frequency frequency = frequencySummary.frequency[Random () .nextInt (frequencySummary.frequency.length)];
47+ Frequency frequency = frequencySummary.frequency[random .nextInt (frequencySummary.frequency.length)];
4648 print ('${frequency .count } occurances from the year ${frequency .year }\n ' );
4749
4850 List <Syllable > syllables = await wordnik.getHyphenation (exampleWord.word);
@@ -52,7 +54,7 @@ void main() async {
5254 exampleWord.word,
5355 limit: 10
5456 );
55- Bigram bigram = bigrams[Random () .nextInt (bigrams.length)];
57+ Bigram bigram = bigrams[random .nextInt (bigrams.length)];
5658 print ('You might say "${bigram .gram1 } ${bigram .gram2 }".\n ' );
5759
5860 List <TextPron > textProns = await wordnik.getTextPronunciations (exampleWord.word);
@@ -65,8 +67,8 @@ void main() async {
6567 );
6668 Related synonyms = relatedWords.firstWhere ((word) => word.relationshipType == 'synonym' );
6769 Related rhymes = relatedWords.firstWhere ((word) => word.relationshipType == 'rhyme' );
68- print ('${synonyms .words .length } synonyms found, including "${synonyms .words [Random () .nextInt (synonyms .words .length )]}".\n ' );
69- print ('${rhymes .words .length } rhymes found, including "${rhymes .words [Random () .nextInt (rhymes .words .length )]}".\n ' );
70+ print ('${synonyms .words .length } synonyms found, including "${synonyms .words [random .nextInt (synonyms .words .length )]}".\n ' );
71+ print ('${rhymes .words .length } rhymes found, including "${rhymes .words [random .nextInt (rhymes .words .length )]}".\n ' );
7072
7173 Example example = await wordnik.getTopExample (exampleWord.word);
7274 print ('The top example is: "${example .text }" from ${example .title }.\n ' );
@@ -128,7 +130,7 @@ void main() async {
128130
129131 List <StringValue > wordsToDelete = List <StringValue >()
130132 ..add (StringValue (word: exampleWord.word))
131- ..add (StringValue (word: randomAdjectives[Random () .nextInt (randomAdjectives.length)].word));
133+ ..add (StringValue (word: randomAdjectives[random .nextInt (randomAdjectives.length)].word));
132134 await wordnik.deleteWordsFromWordList (
133135 authToken.token,
134136 createdWordList.permalink,
@@ -137,7 +139,7 @@ void main() async {
137139 print ('Deleted ${wordsToDelete .length } words from "${createdWordList .name }".\n ' );
138140
139141 WordList modifiedWordList = createdWordList
140- ..description = 'I feel like a ${randomAdjectives [Random () .nextInt (randomAdjectives .length )].word } ${randomNoun .word } ${exampleWord .word }.' ;
142+ ..description = 'I feel like a ${randomAdjectives [random .nextInt (randomAdjectives .length )].word } ${randomNoun .word } ${exampleWord .word }.' ;
141143 await wordnik.updateWordList (
142144 authToken.token,
143145 modifiedWordList.permalink,
0 commit comments