All language subtitles for 43. Getters & else-if

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,210 --> 00:00:03,850 So in result here, 2 00:00:04,760 --> 00:00:11,360 let's add a final property, an int, resultScore or whatever you want to name it, 3 00:00:11,540 --> 00:00:17,870 let's add our constructor and now as a positional argument, though of course you could always use a named 4 00:00:17,900 --> 00:00:19,400 argument if you prefer that 5 00:00:19,520 --> 00:00:22,700 but here I will take this as a positional argument, 6 00:00:22,700 --> 00:00:24,080 my score. 7 00:00:24,080 --> 00:00:30,380 So when we use the result widget here, we now have to forward the score and that of course now is our 8 00:00:30,470 --> 00:00:32,110 total score. 9 00:00:32,120 --> 00:00:38,420 So now the total score which we calculate here in the MyAppState class with the help of our total score 10 00:00:38,470 --> 00:00:39,160 property 11 00:00:39,320 --> 00:00:46,220 and the answerQuestion function, that total score is now forwarded to result and in result, we now 12 00:00:46,220 --> 00:00:51,770 receive this here in the constructor and we automatically, thanks to the shortcut here, store it in the 13 00:00:51,770 --> 00:00:53,620 resultScore property. 14 00:00:53,630 --> 00:01:00,470 Now I just want to output different texts here based on my results score. Now first of all, let's assign 15 00:01:00,470 --> 00:01:05,600 some styling here, we did this earlier, I will do this with the help of the TextStyle class here and the 16 00:01:05,600 --> 00:01:13,940 style argument on my text widget and I want to set the font size here, to let's say 36 and also set the 17 00:01:13,940 --> 00:01:22,400 FontWeight, we haven't done that before to FontWeight.bold. Again FontWeight is here a class and 18 00:01:22,400 --> 00:01:24,220 that is a static property, 19 00:01:24,380 --> 00:01:31,430 again FontWeight therefore is basically a utility, a grouper class which groups a couple of predefined 20 00:01:31,430 --> 00:01:37,980 values and that is basically a value that instructs Flutter to turn this text to bold text. 21 00:01:38,090 --> 00:01:42,950 Still we need different texts and we get different ways of now generating this, 22 00:01:43,760 --> 00:01:50,650 I like the way of adding a getter here. A getter here is a special type of property, 23 00:01:50,750 --> 00:01:54,400 it's basically a mixture of property and method. 24 00:01:54,560 --> 00:01:59,710 You create a getter by first of all defining which type of value you want to get, 25 00:01:59,780 --> 00:02:03,700 you want to derive and that would be a string because I want to get some text, 26 00:02:03,710 --> 00:02:10,470 then you add the get keyword and then any name you want, like resultPhrase. 27 00:02:10,570 --> 00:02:17,320 Now unlike in a method, you now don't add parentheses because a getter is like a method that can never 28 00:02:17,320 --> 00:02:19,390 receive any arguments. 29 00:02:19,390 --> 00:02:25,170 You do add a body though and in that body, you now have to return a string, 30 00:02:25,180 --> 00:02:30,720 you always have to return something in a getter, you use it however like a normal property. 31 00:02:30,790 --> 00:02:32,690 So down there instead of you did it, 32 00:02:32,800 --> 00:02:38,890 I will use resultPhrase and I don't use it with parentheses to execute it like a function, 33 00:02:38,890 --> 00:02:43,610 I'm also not using it as the address of a function because this is no function, 34 00:02:43,630 --> 00:02:45,460 this is simply a Dart feature, 35 00:02:45,520 --> 00:02:52,150 it's a normal property but the value is calculated dynamically and here, the value I want to calculate 36 00:02:52,210 --> 00:02:55,360 is calculated based on the result score. 37 00:02:55,360 --> 00:03:03,850 So in here, in my body of that getter, I'll create a new variable, result 38 00:03:03,880 --> 00:03:13,000 text to avoid name clashes here and I'll assign a default of you did it but then I want to add an if 39 00:03:13,000 --> 00:03:19,800 statement and check if my results score is let's say smaller or equal than 8. 40 00:03:19,870 --> 00:03:31,440 If that is true, then here between the curly braces, I'll set result text equal to you are awesome 41 00:03:31,650 --> 00:03:32,970 and innocent. 42 00:03:35,220 --> 00:03:38,980 So I'm overwriting result text with that new value here, 43 00:03:39,020 --> 00:03:41,790 else if and that's now new, I mentioned it earlier, 44 00:03:41,800 --> 00:03:43,190 we haven't used it thus far, 45 00:03:43,330 --> 00:03:47,450 it's an else statement which kicks in if that condition is not satisfied 46 00:03:47,530 --> 00:03:53,620 but unlike the normal else statement, it does now not blindly execute the code between the curly braces 47 00:03:53,740 --> 00:03:56,180 but it checks another condition first 48 00:03:56,200 --> 00:04:00,340 and here I check if results score is smaller or equal than 12. 49 00:04:00,460 --> 00:04:05,720 So if it's not smaller or equal than 8, then maybe it's smaller or equal than 12. 50 00:04:05,800 --> 00:04:16,230 In that case I would set my result text to pretty likable, with an extra e though. If we don't 51 00:04:16,230 --> 00:04:22,620 make it into there, we can check if the result score is smaller or equal than 16 maybe 52 00:04:22,620 --> 00:04:30,300 and remember that in the way I designed this quiz, higher scores mean a more negative personality. 53 00:04:30,300 --> 00:04:33,690 So in that case, I will set result text to 54 00:04:33,780 --> 00:04:45,320 you are strange and then in all other cases, I will set the result text to 55 00:04:45,520 --> 00:04:48,200 you are so bad. 56 00:04:48,410 --> 00:04:53,030 Now of course since I have that overall else case here, we don't really need an initial value here because 57 00:04:53,030 --> 00:04:57,050 we'll never keep that, we'll certainly at least make it into this else block here. 58 00:04:57,050 --> 00:05:02,300 So we could also get rid of that and in that case as you learned, it's a good practice to define the type 59 00:05:02,810 --> 00:05:06,570 that will be stored in result text in the end which is a string. 60 00:05:06,620 --> 00:05:13,400 Now here in the end, I do return that result text and therefore now when we use resultPhrase down there, 61 00:05:13,580 --> 00:05:18,670 that should be based on the result score we're getting and we should be outputting different results 62 00:05:18,680 --> 00:05:30,000 based on the choice the user made. So let's reload this application here and now let's go for a 63 00:05:30,000 --> 00:05:31,070 negative personality, 64 00:05:31,080 --> 00:05:32,340 so I like black, 65 00:05:32,340 --> 00:05:37,030 I like snakes and here everything is right and we see you are so bad. 66 00:05:37,030 --> 00:05:37,820 Now that's good, 67 00:05:37,860 --> 00:05:40,180 let's restart the app with the green button here. 68 00:05:40,320 --> 00:05:43,670 Of course, it would be nice of a button here but for the moment, we don't have that. 69 00:05:43,760 --> 00:05:44,930 So let's wait for that to reload 70 00:05:44,940 --> 00:05:46,820 and now let's go for a good personality, 71 00:05:46,830 --> 00:05:50,360 white and then I like rabbits 72 00:05:50,380 --> 00:05:51,890 and of course I like myself, 73 00:05:51,910 --> 00:05:54,550 you are awesome and innocent. So that's nice, 74 00:05:54,610 --> 00:06:00,340 one thing of course I notice is the text itself is not centered, so we can quickly do that in the 75 00:06:00,370 --> 00:06:09,750 result.dart file, here on the text widget, we can set textAlign to TextAlign.center, something we also 76 00:06:09,750 --> 00:06:12,660 did earlier and now if we save that, it is centered. 77 00:06:13,260 --> 00:06:15,870 So that's pretty sweet and that's working as it should 78 00:06:15,870 --> 00:06:20,930 as it seems like, we're now showing different results based on different choices and now we have 79 00:06:21,270 --> 00:06:27,540 maybe not the most awesome application we ever built but a realistic application that we could 80 00:06:27,550 --> 00:06:32,070 fine tune and already deploy to the app stores if we wished to do that. 8494

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