All language subtitles for 11. Challenge 1 Solution

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

0 All right. 1

So how did you get on with that challenge? 2

This should be quite simple because we've already done it once for the left dice. But it's important 3

that you understand how it all links together, which is why I wanted you to complete the challenge. 4

The first thing that we need to do is we've got a variable that's tracking the value for our leftDice 5

Number. And it's updating it when the button is pressed. So that it can display a new image in that image 6

widget. 7

Now in order to do the same for the right dice, we're going to need to create a new variable. And we'll 8

just call this rightDice 9

Number, because not feeling too imaginative today. 10

Now once we've got our variable, then we can go about changing it to a random number, when the flap button 11

is pressed. Inside our onPressed, 12

the first thing we're gonna do is we're going to say that our rightDiceNumber is going to equal to 13

a number that's generated from a random number generator. 14

And the specific type of number we want to generate is an integer, 15

so a whole number. And we're going to set the max to six. 16

So we generate random numbers between 0 and 5. And then we'll just add 1 to any of those numbers to bring 17

it up to 1 - 6, which matches with the dice numbers that we have in our images. 18

The next thing we're going to do is we're going to update the place where we use that rightDiceNumber. 19

Instead of pulling up the images/dice1.png, which is pretty much hardcoded, it's always going 20

to be the first image shown. We're going to delete that one, and instead we're going to use a string interpolation 21

to insert the rightDiceNumber inside there. And it's going to be inserted using that little dollar 22

sign there that we saw previously. 23

Now all we have to do is to say that when the rightDiceNumber changes, we should update all the places 24

where it's used. 25

So in order to do that, we have to call that method called set state. 26

And this simply says that this change in the rightDiceNumber's value is going to need to trigger a 27

rebuild of our stateful widget, so that the part where it's used can update on the screen. 28

Let's hit save and for those changes to go through to our app, and let's test it by... we already know the 29

left side works. 30

And now if we click on the right side, it also works. And it gives us all the numbers that we could possibly 31

want. 32

And we now have two separate dice that we can roll on our dice app. 33

Now what if we wanted both dice to change when one of the buttons is pressed? 34

So what if I wanted both of these buttons to update when I click on any one of those buttons? 35

Here is your challenge. 36

Try and get this behavior in your app. So pause the video and try to complete this challenge. 37

And I'll share with you the solution in the next lesson.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.