All language subtitles for 005 Refactoring Stateless to Stateful_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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,030 --> 00:00:04,780 We've now got to appear at the top of our screen, we've got our floating button down at the bottom, 2 00:00:04,780 --> 00:00:05,080 right. 3 00:00:05,230 --> 00:00:07,180 And I think we're making a little bit of progress. 4 00:00:07,600 --> 00:00:12,280 As a quick reminder, the overall goal of our application is to make sure that every time a user presses 5 00:00:12,280 --> 00:00:15,870 the button right here, we show one additional image on the screen. 6 00:00:16,270 --> 00:00:19,920 So if the user presses a button ten times, I want to show 10 images. 7 00:00:20,680 --> 00:00:26,380 Now as we try to build out this application, if we just by line trying to get those images on the screen, 8 00:00:26,530 --> 00:00:29,670 we're going to have to write out a lot of confusing code very quickly. 9 00:00:30,100 --> 00:00:33,420 So I want to take a little bit more incremental approach. 10 00:00:33,820 --> 00:00:38,500 So to get a little bit more incremental approach in building this application, we're going to set ourselves 11 00:00:38,530 --> 00:00:41,290 a little bit easier, more immediate goal. 12 00:00:41,950 --> 00:00:45,940 I want to add in a little piece of text on our screen for right now. 13 00:00:46,690 --> 00:00:49,750 So I want to add like a piece of text right there by default. 14 00:00:49,750 --> 00:00:52,000 I want it to say zero images. 15 00:00:52,540 --> 00:00:57,670 And then every time a user clicks on the button right here, I want to increment this text to stay like 16 00:00:57,670 --> 00:01:01,680 one images, two, three, four, five and so on. 17 00:01:02,440 --> 00:01:07,450 So rather than showing an actual image, we're just going to have a little bit of text that increments 18 00:01:07,450 --> 00:01:09,480 every time the user presses that button. 19 00:01:10,150 --> 00:01:14,110 I know that sounds like it might be a bit boring, but in reality, this little piece of text right 20 00:01:14,110 --> 00:01:16,630 here is very similar to what we're actually trying to do. 21 00:01:17,080 --> 00:01:20,400 Remember, every time we press the button, I want to show an additional image. 22 00:01:20,440 --> 00:01:24,670 So having a little counter is actually not that far off from what we're trying to accomplish. 23 00:01:25,540 --> 00:01:30,700 OK, so let's talk about how we're going to achieve this, because it's actually going to be a little 24 00:01:30,700 --> 00:01:32,770 bit more complicated than you might think. 25 00:01:33,680 --> 00:01:38,960 So I want to first give you a quick reminder on some of the differences between stateless widgets and 26 00:01:38,960 --> 00:01:40,190 stateful widgets. 27 00:01:40,670 --> 00:01:44,670 Now, we looked at this diagram previously, but I changed the text at the bottom just a little bit. 28 00:01:45,560 --> 00:01:48,430 Right now, our app widget is a stateless widget. 29 00:01:48,980 --> 00:01:53,090 That means that it has no instance variables that are going to change over time. 30 00:01:53,240 --> 00:01:56,720 And that's absolutely true of our app widget as it stands right now. 31 00:01:58,110 --> 00:02:05,160 But if we go back to our mockup right over here, clearly as we're pressing on that button, we're going 32 00:02:05,160 --> 00:02:09,150 to need to have some counter variable that's going to change over time. 33 00:02:09,720 --> 00:02:14,760 And I think that is probably going to make sense to tie that counter variable to our app widget. 34 00:02:15,360 --> 00:02:21,720 So because we want to have a piece of information tied to a widget that's going to change over time, 35 00:02:22,200 --> 00:02:25,950 and we want those changes to be reflected on the screen of our device. 36 00:02:26,100 --> 00:02:30,990 We're going to have to refactor our app widget into a stateful widget instead. 37 00:02:32,040 --> 00:02:37,860 So this entire process that we're about to embark upon is going to be refactoring our stateless widget 38 00:02:37,980 --> 00:02:40,260 to be a stateful widget instead. 39 00:02:41,360 --> 00:02:45,710 Now, you might be thinking, OK, Stephen, you know, whatever, that sounds good, let's go back 40 00:02:45,710 --> 00:02:50,960 over to our app components, App Widget right here, and we'll just change stateless widget right here 41 00:02:50,960 --> 00:02:52,230 to stateful. 42 00:02:53,000 --> 00:02:55,700 Well, unfortunately, no, that doesn't quite work out. 43 00:02:55,880 --> 00:02:58,770 So this right here, not quite how we do that refactor. 44 00:02:58,820 --> 00:03:02,840 It's a much more involved process that's going to involve a couple of different steps. 45 00:03:03,680 --> 00:03:06,230 So I want to first tell you about exactly what we're going to do. 46 00:03:06,560 --> 00:03:08,840 Then we're going to do it and we'll talk about what we did. 47 00:03:08,960 --> 00:03:11,240 So we're going to really cover this from all angles. 48 00:03:12,010 --> 00:03:12,500 All right. 49 00:03:12,500 --> 00:03:13,250 So here's the plan. 50 00:03:15,200 --> 00:03:19,730 In this section and the next one, we're going to first get started by doing a refactor of that app 51 00:03:19,730 --> 00:03:24,860 widget into a stateful widget, right after that, we're going to have a quick discussion on a weird 52 00:03:24,860 --> 00:03:27,770 bit of syntax that we're going to see while we are doing that refactor. 53 00:03:28,220 --> 00:03:33,020 And then immediately after that, we'll talk about why these stateful widgets are so much more complicated 54 00:03:33,020 --> 00:03:34,580 to write than stateless ones. 55 00:03:34,640 --> 00:03:34,910 All right. 56 00:03:34,910 --> 00:03:36,620 That's the plan for the next couple of sections. 57 00:03:37,160 --> 00:03:39,320 So let's get started right now with that refactor. 58 00:03:40,290 --> 00:03:44,820 All right, so here's the guide, here's what we need to do, so a couple of different steps in here. 59 00:03:45,450 --> 00:03:49,770 We're going to first get started by breaking our widget, the app widget that we already put together 60 00:03:49,770 --> 00:03:52,860 that class into two separate classes. 61 00:03:53,580 --> 00:03:58,130 We're going to refer to one as the widget itself and then the second class. 62 00:03:58,140 --> 00:04:01,950 And we're going to add in we're going to refer to as the widgets state. 63 00:04:03,150 --> 00:04:08,400 The Wichita State right here is going to be a class that contains the data that we want to wrap up inside 64 00:04:08,400 --> 00:04:09,010 of our widget. 65 00:04:09,180 --> 00:04:14,040 So in our case, it's probably going to be like an integer of some sort that counts the number of times 66 00:04:14,040 --> 00:04:15,420 that user has pressed that button. 67 00:04:16,370 --> 00:04:20,410 So we'll start with this step right here first and we'll move on to the next one in just a moment. 68 00:04:21,470 --> 00:04:27,650 So I'm going to flip back over to my code editor, here's my dirt file with my App Widget, I'm going 69 00:04:27,650 --> 00:04:33,620 to first get started by creating a second class inside of here, right above the existing one. 70 00:04:34,510 --> 00:04:40,450 I'm going to call this class app and it's going to extend stateful widget. 71 00:04:42,220 --> 00:04:47,470 I'll then find the existing app, which we had put together, and I'm going to change the name of this 72 00:04:47,470 --> 00:04:52,210 one from simply app to app state like so. 73 00:04:53,550 --> 00:04:58,050 And then I'm going to change extend statelets, which is right here to something else, and this is 74 00:04:58,050 --> 00:05:01,370 where that weird bit of syntax I just mentioned is going to come into play. 75 00:05:01,890 --> 00:05:03,540 So we're going to write out state. 76 00:05:04,030 --> 00:05:06,570 I'm going to put a less than sign greater than sine. 77 00:05:07,020 --> 00:05:10,110 And then in between those, I'll write out app like so. 78 00:05:11,390 --> 00:05:17,090 OK, so that's step one of our refactor now, like I just said in that diagram two seconds ago, this 79 00:05:17,090 --> 00:05:18,940 is that weird syntax right here. 80 00:05:18,950 --> 00:05:22,930 We're going to have an entire lecture to talk about what exactly is going on right here. 81 00:05:23,180 --> 00:05:24,770 So we will cover this in just a little bit. 82 00:05:24,770 --> 00:05:26,450 But right now, we'll just leave it as is. 83 00:05:27,470 --> 00:05:32,300 All right, so at this point, we have now covered our step one right here of our multi-step process 84 00:05:32,300 --> 00:05:35,330 of refactoring a stateless widget into a stateful widget. 85 00:05:35,840 --> 00:05:37,300 So let's take a quick pause right now. 86 00:05:37,490 --> 00:05:40,010 We'll come back to the next section and we'll move on to step two. 8872

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