All language subtitles for 26. Using Private Properties

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 Download
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
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:02,130 --> 00:00:09,270 So we learned about stateful widgets, the other type of widget you can create in Flutter which differs 2 00:00:09,270 --> 00:00:13,240 from the stateless widget in that it can manage internal data. 3 00:00:13,350 --> 00:00:18,520 Well you could do that in a stateless widget too, you can do that in any Dart class after all 4 00:00:18,660 --> 00:00:24,990 but in a stateful widget if you manage that internal data actually in a state object then which is connected 5 00:00:24,990 --> 00:00:31,440 to the stateful widget, you can update this in a way that it's picked up by Flutter and that UI also 6 00:00:31,440 --> 00:00:33,010 updates. 7 00:00:33,120 --> 00:00:33,660 That's nice, 8 00:00:33,660 --> 00:00:37,710 now let's dive a little bit deeper into Dart at this point, 9 00:00:37,710 --> 00:00:44,520 let me show you one alternative syntax here which I would recommend using because it is a common pattern 10 00:00:44,520 --> 00:00:49,860 and a common practice and you'll see it in other official examples and we'll also use it throughout the 11 00:00:49,860 --> 00:00:53,460 rest of the course. In Dart, 12 00:00:53,460 --> 00:01:00,980 you can have variables on classes like question index and you call these variables properties then and 13 00:01:00,990 --> 00:01:04,100 you can have functions and classes and they are called methods then. 14 00:01:04,220 --> 00:01:05,730 Now that's not new. 15 00:01:05,730 --> 00:01:11,520 Now in Dart, you also can put your code into more than just one file, 16 00:01:11,520 --> 00:01:17,210 we only used one file thus far but actually, I'm already importing something from that material.dart 17 00:01:17,220 --> 00:01:21,020 file which is exposed by the Flutter package. 18 00:01:21,030 --> 00:01:30,300 Now as a default in Dart, every file is its own enclosed ecosystem you could say, it's own so-called 19 00:01:30,480 --> 00:01:36,480 library which can be a confusing name because we have that lib folder and it makes up a a bigger library 20 00:01:36,480 --> 00:01:40,370 but in the end, every file in that folder is its own mini library. 21 00:01:40,410 --> 00:01:46,890 These files can still work together with the help of import statements but you can control what can 22 00:01:46,890 --> 00:01:51,540 be imported and what can be accessed in another file 23 00:01:51,670 --> 00:02:00,210 and for example, you might want to restrict that this state object can be used and changed from inside 24 00:02:00,210 --> 00:02:01,190 another file. 25 00:02:01,230 --> 00:02:03,250 Now we only have that file here, right 26 00:02:03,360 --> 00:02:09,600 but we'll soon add more files and then we want to make sure that we can maybe use our widget in other 27 00:02:09,600 --> 00:02:15,680 files because we are for example also using the MaterialApp or the scaffold widgets which we get from 28 00:02:15,680 --> 00:02:23,250 material.dart but in these widgets, we might not want to grant access to all the properties that are 29 00:02:23,250 --> 00:02:30,030 in there or to this class, we might not want to grant access at all from inside other files because the 30 00:02:30,120 --> 00:02:37,350 only thing that should use this class is the MyApp class here which needs the MyAppState class to 31 00:02:37,350 --> 00:02:39,340 create that state. 32 00:02:39,360 --> 00:02:45,660 Now of course, we as a developer, we are writing our own code and we can simply not use that class anywhere 33 00:02:45,660 --> 00:02:47,070 else and we're fine 34 00:02:47,070 --> 00:02:52,320 but if you are working in a bigger team or if you are sharing your application with other developers, then 35 00:02:52,320 --> 00:02:58,950 you might want to put some protection into place so that the MyAppState can't be used or manipulated 36 00:02:58,950 --> 00:03:05,160 from outside this file because if it could be manipulated from outside, then maybe you could change 37 00:03:05,160 --> 00:03:10,620 question index from inside another file and that wouldn't be picked up by that widget correctly and your 38 00:03:10,620 --> 00:03:17,970 app might therefore get out of sync or you might introduce weird bugs. Now to inform Dart that this 39 00:03:17,970 --> 00:03:21,480 MyAappState class should only be usable from inside the main.dart file, 40 00:03:21,540 --> 00:03:27,600 so from inside the file where it's defined, you add a leading underscore in front of the name and of course 41 00:03:27,600 --> 00:03:31,400 you also have to add that in all the places where you use that name. 42 00:03:31,410 --> 00:03:37,300 Now this might look like a cosmetic thing but actually, that leading underscore is a special syntax 43 00:03:37,310 --> 00:03:44,160 in Dart and it turns this class which normally is a public class, which means it can be used in 44 00:03:44,220 --> 00:03:52,040 any file which imports the main.dart file, this turns it from a public into a private class and now 45 00:03:52,040 --> 00:03:56,110 MyAppState is a class that can only be used inside the main.dart file, 46 00:03:56,210 --> 00:04:02,620 so in our case only in that MyApp class here. And that's what I want because since the state works together 47 00:04:02,630 --> 00:04:06,770 with this class, it should really only be usable inside the same file 48 00:04:06,770 --> 00:04:08,950 where the MyApp class lives. 49 00:04:09,020 --> 00:04:12,070 So that is a common syntax you see 50 00:04:12,080 --> 00:04:22,080 and on the same page, this variable and this method should also only be accessible from inside that file. 51 00:04:22,250 --> 00:04:28,250 Hence we can add an underscore in front of question index and then also again in all the places where 52 00:04:28,250 --> 00:04:35,210 we reference question index to signal that this should be a private property of this class here, 53 00:04:35,420 --> 00:04:41,980 which means we can't access it from anywhere else in our project and let us do the same for this answerQuestion 54 00:04:41,990 --> 00:04:47,690 function or method as it is then called. Let's add an underscore in front of it and then also 55 00:04:47,690 --> 00:04:52,850 add an underscore here. Again, this is basically a convention I'm following here, 56 00:04:52,850 --> 00:04:56,810 however it's not just a cosmetic change, it really has an impact, 57 00:04:56,870 --> 00:04:59,560 it is a syntax understood by Dart. 58 00:04:59,630 --> 00:05:05,420 It doesn't change the way our app works right now but now, we really ensure that MyAppState and all 59 00:05:05,420 --> 00:05:09,980 the properties and methods in there can't be used from anywhere else 60 00:05:09,980 --> 00:05:14,620 than inside this file and that is really important. 6992

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