All language subtitles for 014 The Final Keyword_en

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
fr French
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 Download
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

In the last section, we added a new instance variable to our image list class, but now we see this

error message that says essentially all instance fields must be final.

So the error message is really complaining about this images property that we just added to the image

list in this section.

We're going to talk about a little quick side topic once we learn about this quick side topic will then

come back over to the image list and talk about how the site topic applies over here.

So site topic, I'm going to pull up and dart dart pad very quickly and we'll talk about a new piece

of dirt syntax.

So it's at this point in this course, we've been defining all of our variables by using the VA keyword.

So we've been saying stuff like VA, my name equals Steven or VA.

My number equals whatever.

Right?

Well, it turns out that when we declare a variable with the keyword of VA right here, we're declaring

a certain type of variable or perhaps would be more appropriate to say we are declaring a variable that

is going to be treated in a very specific way by darte.

When we make a variable with the VA keyword, we are telling Dart that we want to declare a variable

with this name that can be reassigned at some point in time in the future.

So after I declare my name right here, I can easily say my name now equals something else where I can

say my number now equals some other number and there's no issue here whatsoever.

So by using the VA keyword, we are declaring a variable that can change over time, it can be reassigned

at some point in the future.

There's another keyword that we can use to declare a variable.

And when we use this other keyword, it declares a variable that behaves a little bit differently.

So one other keyword that we can use to declare a variable is the final keyword when we declare a variable

with the final keyword, let's say a final name equals Steven actually final.

My name, just to be clear.

So when we use that final keyword, it's saying or it's telling D'Arte that we are never going to change

the assignment to this variable.

So after using final, I cannot change the assignment to my name.

So if I try to say my name is now blah, blah, blah, I'm going to see an error message that says that

I'm trying to modify a variable that has already been declared the.

So that in this case, we're not really seeing an error message right here just yet because it's having

a hard time keeping up.

If I click run, we will see the error message appear over here on the right hand side.

Yeah, there we go.

So it says that we are trying to essentially assign some property or assign a value to a variable that

was defined as being final.

So how does this relate to the error message we just saw back over here inside of our Ed?

When we create a stateless widget, remember we said that stateless widgets contain data that should

not change over time because when we create a stateless widget.

Flutter is going to create that thing and then throw it away every time it tries to render our application.

So every time we call the build method inside of our app dart file.

So this thing right here, we're going to be constantly creating new copies of the image list and throwing

them away over and over and over again.

So Flutter wants to make sure.

That you and I don't get it into our heads, that we can change the value of images right here because

in order to change images, we have to create an entire new instance of the image list widget.

So to fix that error message, we need to mark the images variable right here as being final and saying

this is the last value, this thing, it's never going to be changed at any point in time.

So we have to add the final keyword in front of the type declaration like so, and when I add that in

now that error message goes away, we still have the one complaining about the build method.

But we'll take care of that in just a moment.

So, again, any time we have a stateless widget and we try to define a instant's variable on it, we

must mark that variable as being final to say that we do not plan to ever change this variable at any

point in the future.

Now, moving forward, now that we've discussed this final keyword, we're going to be using the final

keyword at several other locations inside of our project, not just for Mirkin Fields as being final

inside of stateless widgets.

It turns out that using the final keyword is actually pretty good practice when you're writing out very

simple functions.

So, for example, back inside of our dirt file.

We can find our fetched image method right here.

We had declared response an image model right here, both with the VA keyword.

However, I think that you can agree with me that in no way, shape or form should we ever change the

assignment of response inside of the Thach image method.

If we do well, that might actually be a pretty big er, you know, if we say something like responses

now, a string or something like that.

So moving forward, you and I are going to define more and more variables that use the final key word

instead, and that's going to keep you and I from accidentally ever redefining variables when we don't

really need to now.

Right now, I'll just leave these as far to keep things unchanged.

But again, moving forward, we're going to see a lot more use of that final keyword.

OK, so we got one error message resolved.

Let's take a quick break and we'll continue in the next section.

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