All language subtitles for 30. Configuring & Using Themes

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,260 --> 00:00:06,940 Regarding the styling, right now our app doesn't really have a uniform style. 2 00:00:06,940 --> 00:00:08,620 We have the blue app bar, 3 00:00:08,740 --> 00:00:14,200 we have the blue chart placeholder, the blue fab, here the floating action button and then the purple 4 00:00:14,230 --> 00:00:15,790 custom style here 5 00:00:15,790 --> 00:00:21,700 and in general thus far when we wanted to style something, like here in transaction list, when I want 6 00:00:21,700 --> 00:00:28,210 to style the color of my amount, of the border around the amount, I had to do that manually with colors 7 00:00:28,210 --> 00:00:30,130 purple. We can do that 8 00:00:30,130 --> 00:00:33,990 but what if we decide that red would be a better color? 9 00:00:34,270 --> 00:00:41,470 Then we manually have to change this here to colors red and we have to change the text color here to 10 00:00:41,470 --> 00:00:42,170 red 11 00:00:42,430 --> 00:00:50,410 and we also have to go to our main.dart file and there, we have to find our app bar and on the app bar, 12 00:00:50,470 --> 00:00:56,600 we can set the background color to colors red. If we do all of that, it saves and yes, it works 13 00:00:56,620 --> 00:01:02,350 and no I don't want to use red but of course, it's pretty cumbersome if we have to change this manually 14 00:01:02,350 --> 00:01:04,260 in all these places. 15 00:01:04,420 --> 00:01:10,390 It would be better if we had a central place of setting these colors and then we could tell Flutter 16 00:01:10,390 --> 00:01:18,220 please use my globally defined color, my primary color, my secondary color and so on 17 00:01:18,220 --> 00:01:22,040 and that's possible with a concept called theming. 18 00:01:22,150 --> 00:01:29,770 We set up an application theme in the main.dart file and there in our MaterialApp. If we scroll up in the 19 00:01:29,770 --> 00:01:33,660 main.dart file, here's our my app widget which is our actual root widget. 20 00:01:33,940 --> 00:01:35,940 There we set up the title for our app, 21 00:01:35,950 --> 00:01:42,010 this by the way is the title you see when the app is in background mode, in the task manager and so on, 22 00:01:42,010 --> 00:01:45,460 so I'll name this personal expenses. 23 00:01:45,460 --> 00:01:49,020 I also want to use this as a title by the way in my app bar, 24 00:01:49,030 --> 00:01:56,020 so here I'll also name this personal expenses but of course the title is not the thing for which I came 25 00:01:56,020 --> 00:01:56,590 there. 26 00:01:56,770 --> 00:02:04,420 Instead here in your MaterialApp, you also can add a theme argument and the theme argument allows you 27 00:02:04,420 --> 00:02:12,130 to set up a global application-wide theme and theme basically means a combination of colors, of text 28 00:02:12,130 --> 00:02:19,810 styles, of font sizes that your entire application uses, that many of Flutter's widgets then use as a default 29 00:02:20,300 --> 00:02:25,560 and that you always can tap into when you want to color your own widgets. 30 00:02:25,630 --> 00:02:27,360 So how does such a theme look like, 31 00:02:27,360 --> 00:02:29,050 how do we define it? 32 00:02:29,050 --> 00:02:35,190 Theme takes a theme data object and now that's not a widget but a normal object based on a class, 33 00:02:35,290 --> 00:02:43,450 the theme data class however is provided by Flutter. Now theme data, as you can tell, has a lot of arguments 34 00:02:43,570 --> 00:02:44,840 which you can configure. 35 00:02:44,860 --> 00:02:47,520 The good thing is you don't have to configure all of them, 36 00:02:47,650 --> 00:02:54,220 a lot of the theme settings are derived from other theme settings so that you only have to define a couple 37 00:02:54,220 --> 00:02:59,550 of main settings unless you really want to control every nitty gritty detail in your app which you also 38 00:02:59,550 --> 00:03:06,520 could if you need that. The most important thing you can define here is the primary swatch. 39 00:03:06,520 --> 00:03:08,530 There also is a primary color, 40 00:03:08,530 --> 00:03:15,040 the difference is that the primary color is one single color, like blue or red and the primary swatch 41 00:03:15,070 --> 00:03:20,860 is based on one single color but it automatically generates different shades of that color automatically 42 00:03:20,860 --> 00:03:21,880 behind the scenes 43 00:03:22,030 --> 00:03:28,690 and many of Flutter's default widgets need these different shades and if you only define your primary 44 00:03:28,690 --> 00:03:34,360 color and not the swatch, then these shades are not available and therefore all these Flutter widgets 45 00:03:34,630 --> 00:03:41,420 will fallback to other defaults or use your primary color which can, in some places, look worse. 46 00:03:41,620 --> 00:03:47,370 So you should define a primary swatch there and what you pass there is still a single color though, 47 00:03:47,440 --> 00:03:50,980 so all these shades are then generated automatically based on the color 48 00:03:50,980 --> 00:03:59,470 you could say. To be really precise, colors gives you a bunch of material color colors and material colors 49 00:03:59,470 --> 00:04:04,840 are more complex objects which have the color itself as well as all the shades included and primary 50 00:04:04,840 --> 00:04:09,760 swatch is then able to pull out these shades. But that's happening behind the scenes, you can simply choose 51 00:04:09,760 --> 00:04:13,440 one of these colors and of course it's totally up to you what you want to use, 52 00:04:13,480 --> 00:04:20,380 I will use purple as my primary color and now also swatch. The effect of that is that 53 00:04:20,390 --> 00:04:26,450 when I go down to the app bar and I make sure that the background color, this red color is removed and 54 00:04:26,450 --> 00:04:32,150 I then save this all, that I automatically get a purple app bar 55 00:04:32,180 --> 00:04:38,960 but also a purple floating action button just because I set this default primary swatch. Of course 56 00:04:38,960 --> 00:04:44,480 here, my boxes are still red because I'm styling these manually, I'm not telling Flutter that I want to 57 00:04:44,480 --> 00:04:54,860 use my theme here. To tell Flutter that I want to use my theme here, I can use theme, which is an object provided 58 00:04:54,860 --> 00:05:01,010 by Flutter and it's available in this file because I'm importing material.dart. So I'm accessing theme 59 00:05:01,010 --> 00:05:08,390 here, then auth context and that in the end is something we also saw on the navigator in the lost 60 00:05:08,390 --> 00:05:11,260 lectures and this in the end just tells Flutter 61 00:05:11,330 --> 00:05:16,910 here's my context object and context is something I get passed to the build method automatically by 62 00:05:16,910 --> 00:05:22,040 Flutter and as I mentioned earlier, context is essentially an object with a lot of metadata about this 63 00:05:22,040 --> 00:05:28,910 widget and its position in the widget tree and one thing context also contains in the end is a reference 64 00:05:28,910 --> 00:05:30,020 to our theme data 65 00:05:30,020 --> 00:05:36,140 you could say. It gives this widget a direct access to our theme data so that we don't have to pass that 66 00:05:36,140 --> 00:05:39,610 theme data down to that widget through the constructor 67 00:05:39,710 --> 00:05:44,840 because if every widget needs to get the theme data through the constructor, you would pass the theme 68 00:05:44,840 --> 00:05:48,230 data around a lot and therefore this is way more convenient, 69 00:05:48,230 --> 00:05:51,290 it gives us a direct tunnel to the theme data. 70 00:05:51,290 --> 00:05:56,960 This is a very elegant way of managing this and that's also a topic we'll dive into later when we talk 71 00:05:56,960 --> 00:06:03,050 about different state management options, where we can pass around our own data in a similar way. 72 00:06:03,080 --> 00:06:07,910 For now, let's just use the theme by getting access to the context which gives us the direct tunnel to 73 00:06:07,910 --> 00:06:10,340 the theme data defined globally 74 00:06:10,340 --> 00:06:18,320 and now there you see you have a bunch of properties. You can for example access the primary color or 75 00:06:18,320 --> 00:06:26,800 if you wanted to, you could access a darker or a lighter version of the primary color, that's that shading 76 00:06:26,800 --> 00:06:32,230 I mentioned, there are different shades. Here I want to use the primary color and I'll do the same here 77 00:06:32,590 --> 00:06:38,530 on my text as a text color, so theme of context primary color. 78 00:06:38,530 --> 00:06:44,770 Now of course I still define my color manually here but I point at the theme and the advantage is that 79 00:06:44,770 --> 00:06:53,650 if I now change my theme, let's say I go back here and I change my theme here to green, then all these 80 00:06:53,650 --> 00:06:59,230 places change simultaneously and you don't have to manually pick and edit all these colors and 81 00:06:59,230 --> 00:07:01,620 that's the huge advantage of using a theme. 82 00:07:02,560 --> 00:07:04,480 I want to go with purple here though 83 00:07:04,480 --> 00:07:11,230 and besides the primary swatch, you'll often also have an accent color. The accent color like the name suggests 84 00:07:11,260 --> 00:07:17,590 is an alternative color because often you want to mix colors and you can look into the official material 85 00:07:17,590 --> 00:07:23,050 design documentation if you want to get ideas for how to mix and match colors and which combinations 86 00:07:23,050 --> 00:07:30,950 work, I really like the amber color, which is a yellowish color combined with purple. If I save this, we 87 00:07:30,950 --> 00:07:37,880 see for example that now that we define that alternative color, the floating action bar is actually configured 88 00:07:37,910 --> 00:07:39,960 to use that accent color. 89 00:07:40,130 --> 00:07:46,280 Remember that floating action button is a default button or a default widget provided by Flutter and 90 00:07:46,280 --> 00:07:51,860 internally, it's simply configured to use the accent color if available and fallback to the primary color 91 00:07:51,860 --> 00:07:53,300 if it's not available 92 00:07:53,420 --> 00:07:54,740 and that's pretty neat. 93 00:07:54,740 --> 00:07:59,870 Here we see the accent color in action and it was just one line of code and something totally different 94 00:07:59,990 --> 00:08:02,440 in our app changed. Now 95 00:08:02,450 --> 00:08:05,340 besides that, you can configure a lot of other things too, 96 00:08:05,390 --> 00:08:11,480 you could for example set the overall app bar theme if you wanted a different theme for the app bar 97 00:08:12,230 --> 00:08:18,380 and so on and we'll come back to that theme data throughout this module and throughout this course. Playing 98 00:08:18,380 --> 00:08:24,730 around with it is something you can always do, at the end of this module in the useful resources lecture, 99 00:08:24,740 --> 00:08:30,140 you'll also find a link to the official theming docs where you can learn more about that and about the 100 00:08:30,140 --> 00:08:36,350 many ways of adjusting this and using themes is a crucial and super important feature in Flutter apps 101 00:08:36,560 --> 00:08:39,620 because it makes styling and coloring so much easier. 11879

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