All language subtitles for 15. Building a Widget Treef

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 Download
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
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:02,460 --> 00:00:09,270 To get a more beautiful app, it would be a good start to have a white background and maybe not this reddish 2 00:00:09,270 --> 00:00:15,960 text with the double yellow underline and we only get this here because I'm outputting the text widget 3 00:00:15,990 --> 00:00:22,710 in the MaterialApp and that is enough to bring something onto the screen but it has no default stylings 4 00:00:22,920 --> 00:00:24,710 for our mobile app. 5 00:00:24,750 --> 00:00:31,680 It does not have any background or any appBar because for Flutter, you have to configure that all manually. 6 00:00:31,680 --> 00:00:38,490 Keep in mind that Flutter controls the entire UI, all the pixels on the screen are controlled by your 7 00:00:38,490 --> 00:00:41,070 Flutter app in the end, by the Flutter framework. 8 00:00:41,220 --> 00:00:48,360 It does not take an existing mobile app and just mix in some widgets or some components, 9 00:00:48,360 --> 00:00:55,080 it controls the entire app instead and therefore you also have to give clear instructions about 10 00:00:55,140 --> 00:00:56,000 every detail, 11 00:00:56,040 --> 00:00:59,190 what should be the background color, should there be an appBar? 12 00:00:59,520 --> 00:01:05,550 And to do that, there is a little helper widget which you can use and I'll replace my text widget here 13 00:01:05,550 --> 00:01:13,180 with it and that's scaffold. Now scaffold is yet another widget which is baked into material.dart. 14 00:01:13,320 --> 00:01:21,290 It's made available there and scaffold has the job of creating a base page design for 15 00:01:21,330 --> 00:01:30,290 your app, so it will give you a basic design and structure and color scheme or coloring for 16 00:01:30,300 --> 00:01:38,220 giving you a UI that looks more like a regular mobile app page. Scaffold also has a couple of named arguments 17 00:01:38,520 --> 00:01:44,660 and you can always hit control space to get some auto completion in the IDE and get a list of the 18 00:01:44,700 --> 00:01:46,920 named arguments that are supported 19 00:01:46,980 --> 00:01:52,890 and here you can also cycle through with the arrow keys to get some help and some explanation of 20 00:01:52,890 --> 00:01:55,870 what each of these named arguments does and 21 00:01:55,880 --> 00:02:01,020 there are tons of arguments and typically, you only use a few of them for each widget you are creating 22 00:02:01,350 --> 00:02:06,840 and here for example we could add an appBar and then a body, body is basically the main content of the 23 00:02:06,840 --> 00:02:10,770 page and appBar as the name suggests is the bar at the top. 24 00:02:10,770 --> 00:02:18,700 So here, we can add appBar and now again appBar if we hover over that takes a preferred size widget. 25 00:02:18,850 --> 00:02:21,270 Now what's a preferred size widget? 26 00:02:21,280 --> 00:02:26,520 Well, it's a special kind of widget you could say, you could build it on your own but since the appBar 27 00:02:26,530 --> 00:02:33,280 is such a typical and specific thing in any application, you can simply pass in a pre-built widget which 28 00:02:33,280 --> 00:02:39,940 is also named appBar. appBar again is a widget provided by material.dart and as always, all widgets 29 00:02:39,940 --> 00:02:40,720 are classes, 30 00:02:40,720 --> 00:02:47,920 so here we are instantiating a class but this is a class which extends stateless or a stateful 31 00:02:47,920 --> 00:02:49,910 widget in the end and appBar 32 00:02:49,930 --> 00:02:55,930 then again take some configuration. So here if I hit control space while being within the parentheses with 33 00:02:55,930 --> 00:02:56,750 my cursor, 34 00:02:56,920 --> 00:03:00,930 I get some explanation on what I can pass here and you can pass a bunch here. 35 00:03:00,940 --> 00:03:08,500 You can pass actions which would be buttons in your appBar, you can pass some of the bottom tabs if 36 00:03:08,500 --> 00:03:10,150 you want to add some tabs in there. 37 00:03:10,150 --> 00:03:15,250 You can change the background color but for now, I only want to set my title, 38 00:03:15,260 --> 00:03:18,740 title is a named argument that allows me to set a title for this page 39 00:03:19,030 --> 00:03:23,400 and here we could add my first app as a title. 40 00:03:23,410 --> 00:03:27,720 However title does not take some text but if we have a look at it, 41 00:03:27,790 --> 00:03:34,500 title actually takes a widget and can always hover over that to see what goes in there. 42 00:03:34,570 --> 00:03:38,550 So it takes a widget, not some text but it takes the text widget and now 43 00:03:38,610 --> 00:03:43,930 this could be confusing but the text widget is not some plain text but this is actually a widget which 44 00:03:43,930 --> 00:03:46,230 takes some plain text, which takes a string 45 00:03:46,240 --> 00:03:52,330 therefore as a positional first argument and then it outputs some text on the screen, the text we're passing 46 00:03:52,330 --> 00:03:55,540 in here but text is a widget, not the plain text. 47 00:03:55,540 --> 00:03:56,950 This here with the quotes, 48 00:03:56,950 --> 00:03:58,470 that is plain text. 49 00:03:58,590 --> 00:04:04,840 So now I'm passing in my text widget, which in turn takes that plain text as a widget for the title argument 50 00:04:05,080 --> 00:04:11,320 in my appBar widget and we already see a bunch of widgets here and whilst this can be confusing initially, 51 00:04:11,320 --> 00:04:18,070 this is how Flutter works, you compose your user interface by mixing multiple widgets together. 52 00:04:18,070 --> 00:04:24,430 So here we have our overall app widget, which then uses a scaffold widget to get some basic page styling, 53 00:04:24,730 --> 00:04:30,010 which then has an appBar widget for its appBar which then takes a text widget. 54 00:04:30,010 --> 00:04:36,300 Now of course, we might not just want an appBar here but also a body, so we can add body here. 55 00:04:36,310 --> 00:04:41,050 Now that's on the scaffold widget, so make sure you are adding this on the right level, outside of the 56 00:04:41,050 --> 00:04:43,330 appBar and outside of the text widget arguments 57 00:04:43,330 --> 00:04:48,420 but on the scaffold arguments, here we can add body and the body here 58 00:04:48,490 --> 00:04:54,440 again could be our text, like this is my default text. 59 00:04:54,450 --> 00:05:02,490 Now one recommendation I have here, always add a comma after closing parentheses because this will allow 60 00:05:02,490 --> 00:05:06,220 you to autoformat this in a very readable way and 61 00:05:06,240 --> 00:05:11,460 that's just a feature the Flutter extension for Visual Studio Code and also for Android Studio offers. 62 00:05:12,210 --> 00:05:19,140 You can format your document with a certain key binding and you can find that if you go to keyboard 63 00:05:19,230 --> 00:05:19,980 shortcuts 64 00:05:20,920 --> 00:05:24,610 and there, you search for format document in Visual Studio Code, 65 00:05:24,640 --> 00:05:29,560 then you should find a key binding which you can also change if you're not happy with the default and with 66 00:05:29,560 --> 00:05:36,890 that key binding if you press that, you auto format your code to be a bit more readable 67 00:05:36,950 --> 00:05:42,860 and with these trailing commas at the end of every line, Flutter is able to format this nicer. If I would 68 00:05:42,860 --> 00:05:45,500 remove this comma after my body argument here, 69 00:05:45,580 --> 00:05:51,830 you'll see now it formats this a bit more unstructured and for short snippets like this, this is 70 00:05:51,830 --> 00:05:57,770 fine but the longer your widget trees get, the easier and nicer it is to read this with these trailing 71 00:05:57,770 --> 00:06:03,870 commas which improve the auto formatting but that's just a tiny hint for writing clean code. 72 00:06:03,890 --> 00:06:09,410 So with that, we finished our scaffold widget which we didn't create ourselves but which is provided 73 00:06:09,410 --> 00:06:10,390 by Flutter and 74 00:06:10,460 --> 00:06:12,740 we passed an appBar and a body. 75 00:06:12,740 --> 00:06:19,520 And now if we save this, it should automatically rebuild and hot reload your application. Hot reload means 76 00:06:19,520 --> 00:06:25,340 that it didn't need to restart the app, which means it keeps the current state, if we change any 77 00:06:25,340 --> 00:06:27,770 data in there, it wouldn't restart and override that, 78 00:06:27,860 --> 00:06:34,280 instead it keeps the app as it was and just injects our new code into it, which is some magic managed 79 00:06:34,310 --> 00:06:39,770 by Flutter during development and therefore if we go back, now this looks way better. Instead of that 80 00:06:39,890 --> 00:06:44,520 ugly hello which was red with a black default, with a black background, 81 00:06:44,570 --> 00:06:50,840 we now have our nicer page look here with an appBar, with a little drop shadow, with a blue background, 82 00:06:51,050 --> 00:06:56,630 with our title that automatically has a color that contrasts against the background 83 00:06:56,630 --> 00:06:57,550 and then here we have 84 00:06:57,540 --> 00:07:01,070 this is my default text which we output in the body, 85 00:07:01,070 --> 00:07:07,790 so in the main area of this page. And this is how we build Flutter apps, how we work with these widget 86 00:07:07,790 --> 00:07:14,390 trees and how we can also structure our app here in code and that is what I meant when I mentioned in 87 00:07:14,390 --> 00:07:20,810 the first section that with Flutter and Dart, we build mobile apps by building the user interface in 88 00:07:20,810 --> 00:07:24,040 code. We're not using a drag and drop editor here, 89 00:07:24,140 --> 00:07:28,460 instead we're writing some code which defines what should end up on the screen. 90 00:07:29,030 --> 00:07:31,490 And now we have these basic set, 91 00:07:31,610 --> 00:07:37,970 let's take the next step towards our first, a little bit more realistic course application. 10474

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