All language subtitles for 22. Adding User Transactions to the List

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,370 --> 00:00:03,510 Were you successful? 2 00:00:03,510 --> 00:00:09,260 Let's wire it up together and for this, let's go to the new transaction file and here for onPressed, 3 00:00:09,870 --> 00:00:13,920 I now want to call that add new transaction method. 4 00:00:13,920 --> 00:00:19,100 The problem just is this method is a private method in a private class in a different file, 5 00:00:19,140 --> 00:00:23,460 so there is no way how we can access it directly. 6 00:00:23,460 --> 00:00:25,060 Well actually there is a way. 7 00:00:25,170 --> 00:00:30,490 Remember that this in the end also just creates a pointer at this function here in the end, 8 00:00:30,750 --> 00:00:34,460 we can pass that pointer down to a new transaction 9 00:00:34,470 --> 00:00:43,290 So here to new transaction, I can pass add new transaction, so I can pass basically that function pointer 10 00:00:43,290 --> 00:00:46,120 here by the name without adding parentheses, 11 00:00:46,260 --> 00:00:51,690 if we would add parentheses, we would immediately execute this when Dart parses this line, without parentheses 12 00:00:51,690 --> 00:00:53,770 we just pass down the pointer. 13 00:00:53,850 --> 00:00:57,030 Now in new transaction, we need to accept that pointer. 14 00:00:57,030 --> 00:01:07,540 So here I'll add a new final property which is of type function, which I'll name addTx or whatever 15 00:01:07,540 --> 00:01:08,790 you want to name it 16 00:01:08,950 --> 00:01:13,930 and that should be set with the help of the constructor of new transaction because we're passing something 17 00:01:13,930 --> 00:01:19,750 to the constructor here in user transactions and therefore we should provide such a constructor here 18 00:01:19,870 --> 00:01:20,770 in new transaction. 19 00:01:21,250 --> 00:01:29,450 So add new transaction and bind whatever you get to addTx, so not whatever you get, 20 00:01:29,470 --> 00:01:34,150 of course we know that what we get will be a pointer at a function and we bind that pointer into the 21 00:01:34,270 --> 00:01:41,200 addTx variable here. Since addTx holds a pointer at a function, we can now execute it like a function here. In 22 00:01:41,200 --> 00:01:44,170 onPressed, we can execute addTx 23 00:01:44,170 --> 00:01:50,650 and now here we need to pass the value for our title and also the value for our amount. 24 00:01:51,490 --> 00:01:52,570 So here I'll pass 25 00:01:52,570 --> 00:01:59,260 titleController.text and also amountController.text. 26 00:01:59,260 --> 00:02:04,290 Now here's one tiny issue, text here always returns us a string 27 00:02:04,480 --> 00:02:12,030 but actually in our ad new transaction method here, we expect the amount to be a double. 28 00:02:12,100 --> 00:02:23,080 Now to convert that string to a double, you can go to new transaction and actually use double.parse 29 00:02:23,100 --> 00:02:30,300 and this will take a string and convert it to a double. Now important, if you entered a text that can't 30 00:02:30,300 --> 00:02:31,150 be converted, 31 00:02:31,230 --> 00:02:36,240 something like hello, then this will throw an error and your app will break. 32 00:02:36,240 --> 00:02:41,250 So in reality, you might want to also provide some logic that would handle such an error 33 00:02:41,250 --> 00:02:45,810 but since we haven't learned that yet and it's not that important right now, we'll handle errors later, 34 00:02:46,170 --> 00:02:46,620 for now 35 00:02:46,620 --> 00:02:49,550 be aware that you have to enter a valid number here, otherwise 36 00:02:49,560 --> 00:02:54,640 this will break. Now with that, everything is wired up. 37 00:02:54,640 --> 00:02:57,610 If we save this and we go back, that's looking good 38 00:02:57,610 --> 00:03:02,820 and now let's give this a try, enter test here and here as I said enter number, also important, 39 00:03:02,830 --> 00:03:09,850 that number needs to use a dot as a decimal place and now hit add transaction and you see it gets added 40 00:03:09,850 --> 00:03:11,710 here, which is of course pretty sweet. 41 00:03:12,940 --> 00:03:17,570 And of course we can add as many transactions here as we want, 42 00:03:17,770 --> 00:03:27,160 we can press this button over and over again, at some point however, we'll face a problem. If I enter more 43 00:03:27,160 --> 00:03:33,930 and more here, you see now we have that warning which we saw before already, this yellow black thing 44 00:03:33,930 --> 00:03:34,600 here, 45 00:03:34,800 --> 00:03:38,410 we now already see that even without the keyboard opened. 46 00:03:38,430 --> 00:03:40,790 So we should finally tackle what the issue here is 47 00:03:41,070 --> 00:03:43,860 and to give you a hint, it's related to another problem, 48 00:03:44,010 --> 00:03:45,820 we can't scroll this list, 49 00:03:45,840 --> 00:03:49,940 there is no way we can see the new transaction we added at the bottom. 50 00:03:50,270 --> 00:03:55,150 And that's not a bug, that's a default behavior which we can easily fix and we will fix it 51 00:03:55,170 --> 00:03:55,920 in the next lecture. 5311

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