All language subtitles for 014 The Final Keyword_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian Download
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,810 --> 00:00:06,180 In the last section, we added a new instance variable to our image list class, but now we see this 2 00:00:06,180 --> 00:00:10,450 error message that says essentially all instance fields must be final. 3 00:00:10,860 --> 00:00:16,140 So the error message is really complaining about this images property that we just added to the image 4 00:00:16,140 --> 00:00:17,760 list in this section. 5 00:00:17,760 --> 00:00:23,190 We're going to talk about a little quick side topic once we learn about this quick side topic will then 6 00:00:23,190 --> 00:00:26,900 come back over to the image list and talk about how the site topic applies over here. 7 00:00:27,480 --> 00:00:33,360 So site topic, I'm going to pull up and dart dart pad very quickly and we'll talk about a new piece 8 00:00:33,360 --> 00:00:34,560 of dirt syntax. 9 00:00:35,220 --> 00:00:39,740 So it's at this point in this course, we've been defining all of our variables by using the VA keyword. 10 00:00:39,810 --> 00:00:44,760 So we've been saying stuff like VA, my name equals Steven or VA. 11 00:00:44,760 --> 00:00:47,130 My number equals whatever. 12 00:00:47,130 --> 00:00:47,450 Right? 13 00:00:48,570 --> 00:00:53,580 Well, it turns out that when we declare a variable with the keyword of VA right here, we're declaring 14 00:00:53,580 --> 00:01:00,090 a certain type of variable or perhaps would be more appropriate to say we are declaring a variable that 15 00:01:00,120 --> 00:01:03,090 is going to be treated in a very specific way by darte. 16 00:01:03,930 --> 00:01:09,690 When we make a variable with the VA keyword, we are telling Dart that we want to declare a variable 17 00:01:09,690 --> 00:01:14,400 with this name that can be reassigned at some point in time in the future. 18 00:01:15,210 --> 00:01:22,890 So after I declare my name right here, I can easily say my name now equals something else where I can 19 00:01:22,890 --> 00:01:28,710 say my number now equals some other number and there's no issue here whatsoever. 20 00:01:30,330 --> 00:01:36,990 So by using the VA keyword, we are declaring a variable that can change over time, it can be reassigned 21 00:01:36,990 --> 00:01:38,100 at some point in the future. 22 00:01:38,820 --> 00:01:42,240 There's another keyword that we can use to declare a variable. 23 00:01:42,540 --> 00:01:47,720 And when we use this other keyword, it declares a variable that behaves a little bit differently. 24 00:01:49,400 --> 00:01:56,240 So one other keyword that we can use to declare a variable is the final keyword when we declare a variable 25 00:01:56,570 --> 00:02:01,850 with the final keyword, let's say a final name equals Steven actually final. 26 00:02:01,880 --> 00:02:02,980 My name, just to be clear. 27 00:02:04,100 --> 00:02:09,740 So when we use that final keyword, it's saying or it's telling D'Arte that we are never going to change 28 00:02:09,740 --> 00:02:11,980 the assignment to this variable. 29 00:02:12,500 --> 00:02:16,460 So after using final, I cannot change the assignment to my name. 30 00:02:16,490 --> 00:02:22,130 So if I try to say my name is now blah, blah, blah, I'm going to see an error message that says that 31 00:02:22,130 --> 00:02:26,420 I'm trying to modify a variable that has already been declared the. 32 00:02:26,700 --> 00:02:31,250 So that in this case, we're not really seeing an error message right here just yet because it's having 33 00:02:31,250 --> 00:02:32,300 a hard time keeping up. 34 00:02:32,490 --> 00:02:36,050 If I click run, we will see the error message appear over here on the right hand side. 35 00:02:36,170 --> 00:02:36,890 Yeah, there we go. 36 00:02:37,490 --> 00:02:43,700 So it says that we are trying to essentially assign some property or assign a value to a variable that 37 00:02:43,700 --> 00:02:45,290 was defined as being final. 38 00:02:46,150 --> 00:02:51,580 So how does this relate to the error message we just saw back over here inside of our Ed? 39 00:02:52,670 --> 00:02:58,190 When we create a stateless widget, remember we said that stateless widgets contain data that should 40 00:02:58,190 --> 00:03:02,300 not change over time because when we create a stateless widget. 41 00:03:03,380 --> 00:03:08,870 Flutter is going to create that thing and then throw it away every time it tries to render our application. 42 00:03:09,380 --> 00:03:14,360 So every time we call the build method inside of our app dart file. 43 00:03:14,570 --> 00:03:19,700 So this thing right here, we're going to be constantly creating new copies of the image list and throwing 44 00:03:19,700 --> 00:03:21,650 them away over and over and over again. 45 00:03:22,460 --> 00:03:24,080 So Flutter wants to make sure. 46 00:03:25,110 --> 00:03:30,240 That you and I don't get it into our heads, that we can change the value of images right here because 47 00:03:30,240 --> 00:03:35,850 in order to change images, we have to create an entire new instance of the image list widget. 48 00:03:37,180 --> 00:03:43,240 So to fix that error message, we need to mark the images variable right here as being final and saying 49 00:03:43,270 --> 00:03:47,820 this is the last value, this thing, it's never going to be changed at any point in time. 50 00:03:48,790 --> 00:03:54,820 So we have to add the final keyword in front of the type declaration like so, and when I add that in 51 00:03:55,450 --> 00:03:59,410 now that error message goes away, we still have the one complaining about the build method. 52 00:03:59,410 --> 00:04:00,820 But we'll take care of that in just a moment. 53 00:04:01,660 --> 00:04:07,330 So, again, any time we have a stateless widget and we try to define a instant's variable on it, we 54 00:04:07,330 --> 00:04:12,910 must mark that variable as being final to say that we do not plan to ever change this variable at any 55 00:04:12,910 --> 00:04:13,610 point in the future. 56 00:04:14,380 --> 00:04:19,390 Now, moving forward, now that we've discussed this final keyword, we're going to be using the final 57 00:04:19,390 --> 00:04:25,510 keyword at several other locations inside of our project, not just for Mirkin Fields as being final 58 00:04:25,510 --> 00:04:27,070 inside of stateless widgets. 59 00:04:27,610 --> 00:04:32,830 It turns out that using the final keyword is actually pretty good practice when you're writing out very 60 00:04:32,830 --> 00:04:33,740 simple functions. 61 00:04:34,090 --> 00:04:37,000 So, for example, back inside of our dirt file. 62 00:04:38,090 --> 00:04:40,410 We can find our fetched image method right here. 63 00:04:41,000 --> 00:04:46,430 We had declared response an image model right here, both with the VA keyword. 64 00:04:46,860 --> 00:04:53,240 However, I think that you can agree with me that in no way, shape or form should we ever change the 65 00:04:53,240 --> 00:04:56,390 assignment of response inside of the Thach image method. 66 00:04:57,280 --> 00:05:02,680 If we do well, that might actually be a pretty big er, you know, if we say something like responses 67 00:05:02,680 --> 00:05:04,330 now, a string or something like that. 68 00:05:05,410 --> 00:05:10,750 So moving forward, you and I are going to define more and more variables that use the final key word 69 00:05:10,750 --> 00:05:16,720 instead, and that's going to keep you and I from accidentally ever redefining variables when we don't 70 00:05:16,720 --> 00:05:18,270 really need to now. 71 00:05:18,370 --> 00:05:21,210 Right now, I'll just leave these as far to keep things unchanged. 72 00:05:21,220 --> 00:05:24,640 But again, moving forward, we're going to see a lot more use of that final keyword. 73 00:05:26,470 --> 00:05:28,640 OK, so we got one error message resolved. 74 00:05:28,840 --> 00:05:31,270 Let's take a quick break and we'll continue in the next section. 7926

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