All language subtitles for 001 Stateless vs Stateful Widgets_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,910 --> 00:00:06,580 In the last section, we started extracting some logic from our main dirt file over to this new custom 2 00:00:06,580 --> 00:00:11,080 app widget that we have started working on, we got through comment number one up here. 3 00:00:11,110 --> 00:00:14,940 And we're now going to continue with the second step, which is the second coming right here. 4 00:00:15,430 --> 00:00:21,970 So in the second step, we need to create a class that is going to extend the base stateless widget 5 00:00:21,970 --> 00:00:24,030 class to do so. 6 00:00:24,040 --> 00:00:27,430 We're going to first just write out the code for this and we'll talk about what it's doing. 7 00:00:27,970 --> 00:00:34,750 So the code that we need right here is a class app extends stateless widgets. 8 00:00:35,700 --> 00:00:41,320 OK, you might see a little red squiggly under that that says missing concrete implementation. 9 00:00:41,340 --> 00:00:43,200 You can completely ignore that error message. 10 00:00:43,240 --> 00:00:45,420 Right now, we're going to fix that up in just a moment. 11 00:00:45,990 --> 00:00:51,120 What's more important is what's going on with the syntax right here and even more importantly, what 12 00:00:51,120 --> 00:00:52,590 a stateless widget is. 13 00:00:53,160 --> 00:00:54,630 So, first off, the syntax. 14 00:00:55,320 --> 00:01:01,350 This defines a new class called app that's going to take all the functionality inside of the base class 15 00:01:01,350 --> 00:01:05,129 of stateless widget and add some additional methods. 16 00:01:05,129 --> 00:01:06,870 In instance, variables on top. 17 00:01:07,990 --> 00:01:13,150 This right here is classic object oriented programming, so we're taking a base class and extending 18 00:01:13,150 --> 00:01:20,530 it with some additional functionality, we would now refer to our class app as a subclass of stateless 19 00:01:20,530 --> 00:01:20,980 widget. 20 00:01:22,340 --> 00:01:27,350 OK, so the idea of extending a class, again, classic Opta to programming, not the worst thing in 21 00:01:27,350 --> 00:01:32,630 the world, what is a little bit more confusing is exactly what a stateless widget is. 22 00:01:32,990 --> 00:01:35,540 So let's take a look at a diagram that's going to clarify that. 23 00:01:39,590 --> 00:01:44,570 So in the last couple of sections, I've been using the term widget over and over and over, a widget 24 00:01:44,570 --> 00:01:50,660 and flutter is not only a concept of something that controls some element that gets displayed on the 25 00:01:50,660 --> 00:01:53,770 screen of our mobile device, but it's also a class. 26 00:01:54,230 --> 00:02:00,260 So in flutter there is a class called Widget and it contains a bunch of functions and different instance 27 00:02:00,260 --> 00:02:03,770 variables that assisted in showing some content on the screen of our device. 28 00:02:05,180 --> 00:02:08,960 From this widget class, there are two subclasses. 29 00:02:09,440 --> 00:02:13,410 One is called Stateless Widget and the other one is called stateful. 30 00:02:14,390 --> 00:02:19,760 There's one difference between these two classes and it solely comes down to whether or not the widget 31 00:02:19,760 --> 00:02:24,590 that we're trying to create is going to maintain its own state or its own data. 32 00:02:25,440 --> 00:02:31,080 So if we are creating a custom widget where we expect our which to to never have to like essentially 33 00:02:31,080 --> 00:02:35,370 maintain its own source of data, we will create a stateless widget. 34 00:02:36,150 --> 00:02:41,220 If we expect to have to create a custom widget that's going to eventually have to control its own source 35 00:02:41,220 --> 00:02:48,240 of data or go fetch its own data or somehow generate and maintain its own state, we will instead create 36 00:02:48,390 --> 00:02:49,470 a stateful widget. 37 00:02:50,430 --> 00:02:55,560 Now, if these terms of, like maintain data and state don't make any sense to you, that's totally 38 00:02:55,570 --> 00:02:55,910 fine. 39 00:02:56,070 --> 00:02:57,840 Let me try putting this a different way. 40 00:02:59,630 --> 00:03:05,510 If you are trying to create a widget, as we are right here, and you expect this thing to eventually 41 00:03:05,510 --> 00:03:11,900 have to maintain its own local instance variable, that has to change over time, like, let's say we're 42 00:03:11,900 --> 00:03:13,520 making some counting application. 43 00:03:13,760 --> 00:03:16,940 And for that, we would want to make some like counter variable. 44 00:03:18,270 --> 00:03:24,090 That starts off at zero and then we would maybe want to increment this counter over time, if you expect 45 00:03:24,090 --> 00:03:28,800 to have to write code like this right here, then you do not want a stateless widget. 46 00:03:29,340 --> 00:03:35,580 We only use a stateless widget when we do not expect to have to add in an instance variable that's going 47 00:03:35,580 --> 00:03:36,180 to change. 48 00:03:37,230 --> 00:03:43,830 In our case, our app widget for right now does really not appear to have any data tied to it that's 49 00:03:43,830 --> 00:03:45,010 going to change over time. 50 00:03:45,630 --> 00:03:50,030 Now, once we add in this idea of fetching images and whatnot, maybe that's going to change. 51 00:03:50,250 --> 00:03:56,430 But right now, just for what we have at this point in time, it has no data tied to it that's going 52 00:03:56,430 --> 00:03:57,060 to change. 53 00:03:57,300 --> 00:04:02,700 And that's why I chose to use a stateless widget right here rather than a stateful widget. 54 00:04:03,840 --> 00:04:05,920 OK, so that's step number two. 55 00:04:06,030 --> 00:04:09,810 Now, let's again take a quick break, we're going to come back to the next section and we're going 56 00:04:09,810 --> 00:04:12,590 to start working on this build method thing right here. 57 00:04:12,600 --> 00:04:14,640 So quick break and we'll see you in just a minute. 6025

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