All language subtitles for 19. Fetching User Input

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,280 --> 00:00:06,930 So having the button is good, but of course, you want to actually add a new transaction when we press 2 00:00:06,930 --> 00:00:10,170 it for dad, we first of all need to collect the user input. 3 00:00:10,620 --> 00:00:12,280 It's good that we have these text fields. 4 00:00:12,330 --> 00:00:15,180 But how can we get access to what the user entered? 5 00:00:16,140 --> 00:00:18,270 There are two ways of getting access. 6 00:00:18,450 --> 00:00:19,950 It's up to you which one you choose. 7 00:00:19,950 --> 00:00:22,940 It also depends on the complexity of the form you're building. 8 00:00:23,640 --> 00:00:29,370 The first way of getting access is that you simply saved the user input with every keystroke that you 9 00:00:29,370 --> 00:00:31,680 save it in a property. 10 00:00:32,550 --> 00:00:38,640 Now, for that, we need a property in which we can save it and we can add it here to our widget. 11 00:00:38,670 --> 00:00:41,550 But keep in mind that this is a stateless widget. 12 00:00:41,730 --> 00:00:42,690 And what does this mean? 13 00:00:43,620 --> 00:00:49,270 It means that any data we have in there, like the transactions property is immutable. 14 00:00:49,350 --> 00:00:50,460 We can't change it. 15 00:00:50,610 --> 00:00:57,570 Well, technically, we can change it, but our changes will never be reflected on the user interface. 16 00:00:58,410 --> 00:01:04,150 Now, actually, here, that wouldn't be a problem because with every keystroke we could save the day 17 00:01:04,170 --> 00:01:09,090 that a user entered and then only do something once we hit a button. 18 00:01:09,510 --> 00:01:16,320 So it's actually okay if we just save changes without updating the user interface because there is no 19 00:01:16,320 --> 00:01:16,740 update. 20 00:01:16,750 --> 00:01:18,510 We want to perform with every keystroke. 21 00:01:18,600 --> 00:01:20,610 We just want to save the data behind the scenes. 22 00:01:21,030 --> 00:01:25,950 And we can do that because a stateless widget is still a objects to look normal class. 23 00:01:26,250 --> 00:01:28,440 So we can't have properties in there, which we can change. 24 00:01:28,650 --> 00:01:30,690 We just can't rerun the build method. 25 00:01:30,810 --> 00:01:32,460 We can't use set state here. 26 00:01:32,670 --> 00:01:34,040 But again, that won't be needed. 27 00:01:35,030 --> 00:01:43,340 So what you can do, therefore, is you can add new properties here to your class maybe. 28 00:01:45,470 --> 00:01:54,720 A string title input and another string amount input, that's, by the way, important, the input values 29 00:01:54,780 --> 00:01:57,240 are always strings by default. 30 00:01:57,270 --> 00:02:02,640 If you need a different value, like a number here for the amount, then you need to convert it manually. 31 00:02:04,090 --> 00:02:05,620 So we have these two strings. 32 00:02:06,310 --> 00:02:11,290 And now if we go down to our textfield stair, you can add the on changed listener. 33 00:02:12,070 --> 00:02:14,890 Now on changed will fire with every keystroke. 34 00:02:15,520 --> 00:02:20,710 As you see, you have a couple of our listeners to on editing complete as fired when the user presses 35 00:02:20,710 --> 00:02:24,940 the Dunn Go or next or whatever it is, button into soft keyboard. 36 00:02:25,060 --> 00:02:29,560 So that would basically be that button in the bottom right corner that can have a different look and 37 00:02:29,650 --> 00:02:30,160 meaning. 38 00:02:30,430 --> 00:02:32,320 And you can configure that actually by way. 39 00:02:32,320 --> 00:02:33,930 You can ignore this here for now. 40 00:02:33,970 --> 00:02:40,420 This strange yellow thing, your so that is on editing complete that it's fired when that button is 41 00:02:40,420 --> 00:02:41,320 pressed on. 42 00:02:41,320 --> 00:02:47,740 Submitted is kind of related, but this fires whenever the done button is pressed. 43 00:02:47,770 --> 00:02:51,160 So not on every button in the bottom right corner basically, but only for that. 44 00:02:51,270 --> 00:02:55,900 Dunbarton and if you configured your text few to show a different button there then would not fire. 45 00:02:56,320 --> 00:02:59,230 And on tap is fired whenever you tap into the textfield. 46 00:02:59,980 --> 00:03:06,850 Now, here we need unchanged because unchanged fires for every keystroke on changed then requires us 47 00:03:06,850 --> 00:03:11,830 to pass a reference, a pointer at a function which takes a string value. 48 00:03:11,950 --> 00:03:17,350 So not a function that has no arguments, but a function that accepts exactly one argument, which is 49 00:03:17,350 --> 00:03:18,160 of type string. 50 00:03:18,580 --> 00:03:20,110 And that then returns nothing. 51 00:03:20,770 --> 00:03:25,360 You can use a named function here or you define an anonymous function. 52 00:03:25,450 --> 00:03:30,790 However, as it just explained, it needs to be a function which takes value. 53 00:03:31,360 --> 00:03:37,510 You don't need to add to type here because Dart is smart enough to infer this because on changed expects 54 00:03:37,510 --> 00:03:39,700 a function that takes a string argument. 55 00:03:40,270 --> 00:03:43,900 Dart automatically understands that value here will be of type string. 56 00:03:44,290 --> 00:03:45,790 You also don't have to name this value. 57 00:03:45,800 --> 00:03:47,260 You can name it Val, whatever you want. 58 00:03:48,100 --> 00:03:49,510 So now we get this. 59 00:03:49,510 --> 00:03:50,620 We have this function. 60 00:03:50,650 --> 00:03:52,390 It will be triggered for every keystroke. 61 00:03:52,810 --> 00:03:58,840 And then in here, since we're editing the title here, we can set title input equal to velt. 62 00:03:59,200 --> 00:04:05,680 So that means we overwrite the current value of title input with the input the user chose here. 63 00:04:05,710 --> 00:04:09,700 So with the current input off that text, input off the TextField. 64 00:04:10,620 --> 00:04:11,940 We can do the same for the amount. 65 00:04:12,450 --> 00:04:19,290 Add on changed here, gets to value and then we can all use Ted Shorter notation with the arrow because 66 00:04:19,290 --> 00:04:20,970 we have only one expression. 67 00:04:21,340 --> 00:04:25,230 Dear, we can set amount input equal to VLT. 68 00:04:26,650 --> 00:04:30,100 With that, we have a setup where we register every keystroke. 69 00:04:30,490 --> 00:04:35,520 And now we save that in our title input and any amount input. 70 00:04:36,430 --> 00:04:41,680 Again, the UI won't be updated because we're not calling set state and we couldn't call it because 71 00:04:41,710 --> 00:04:42,250 we're in a state. 72 00:04:42,280 --> 00:04:42,760 This widget. 73 00:04:42,910 --> 00:04:44,500 But that's not required here. 74 00:04:45,690 --> 00:04:52,710 To prove that it worked here, when we pressed that ad transaction button, I will print the title input 75 00:04:52,710 --> 00:04:56,620 so the value is stored in there and also the amount input. 76 00:04:57,540 --> 00:04:58,650 Let's save all of that. 77 00:04:59,660 --> 00:05:04,670 And again, you can't ignore this yellow black thing, you're at the bottom. 78 00:05:04,700 --> 00:05:06,920 I will explain what's up with that later. 79 00:05:07,370 --> 00:05:13,730 And for the moment, we can enter some amount here, like twelve dot ninety nine. 80 00:05:14,180 --> 00:05:16,130 And here we can enter a title like. 81 00:05:17,300 --> 00:05:20,350 Test and you could use your physical keyboard for this, too. 82 00:05:20,930 --> 00:05:28,230 If you don't hit ad transaction, you see test and 12 99 output here because these values were saved 83 00:05:28,250 --> 00:05:31,370 with every keystroke and therefore we can also use them. 84 00:05:31,820 --> 00:05:36,110 The only thing we can do right now is update our user interface based on that. 85 00:05:37,840 --> 00:05:40,690 Registering the input on every keystroke is perfectly fine. 86 00:05:41,260 --> 00:05:44,830 However, here, Flattr actually complains or gives us a warning. 87 00:05:45,220 --> 00:05:49,540 That is my home page Closs, which is marked as immutable. 88 00:05:49,630 --> 00:05:56,110 That's basically a flag to stateless, which it sets, has a field, a property which changes or which 89 00:05:56,110 --> 00:05:56,860 is not final. 90 00:05:56,920 --> 00:05:57,400 That's true. 91 00:05:57,400 --> 00:05:59,500 Title input and amount input are not final. 92 00:05:59,530 --> 00:06:00,580 They can change. 93 00:06:01,030 --> 00:06:03,880 And actually the case we have here is a pretty neat case. 94 00:06:04,300 --> 00:06:10,090 Normally you don't have changeable properties in a stateless widget because you can't update UI based 95 00:06:10,090 --> 00:06:11,290 on these changes anyways. 96 00:06:11,830 --> 00:06:16,630 This is one of the rare cases where we save some data and where we are perfectly fine with that, having 97 00:06:16,630 --> 00:06:18,940 no direct impact on the user interface. 98 00:06:19,480 --> 00:06:25,180 Still, you might want to consider turning this entire widget into a state full widget to get rid of 99 00:06:25,180 --> 00:06:25,830 that wording. 100 00:06:26,080 --> 00:06:33,760 And also to avoid an error which will run into later or a little issue which will run into later, which 101 00:06:33,760 --> 00:06:34,960 it will fix later, though. 102 00:06:35,050 --> 00:06:37,180 So we'll then see how to work around that. 103 00:06:37,810 --> 00:06:42,340 Nonetheless, for the moment, this year will work and we can leave it like this for the moment. 104 00:06:43,750 --> 00:06:45,310 Now we'll have a problem anyways. 105 00:06:45,880 --> 00:06:48,310 I, of course, don't just want to print my results here. 106 00:06:48,640 --> 00:06:52,930 I want to create a new element or new transaction. 107 00:06:53,050 --> 00:06:59,530 And Dad, in the end should then also lead to some output on the screen because transactions are a list 108 00:06:59,530 --> 00:07:02,950 here should then actually change and hold that new transaction. 109 00:07:03,430 --> 00:07:04,030 So. 110 00:07:05,650 --> 00:07:11,830 We'll have to switch to a stateful, which is at some point anyways before we do so, however, let 111 00:07:11,830 --> 00:07:17,740 me first of all show you an alternative to registering this manually on every keystroke whilst you can 112 00:07:17,740 --> 00:07:18,170 do this. 113 00:07:18,190 --> 00:07:22,900 And whilst this is especially useful, if you have more complex logic that you maybe want to run on, 114 00:07:22,900 --> 00:07:28,780 every keystroke, flutter actually has a built in mechanism that allows you to listen to every keystroke 115 00:07:28,780 --> 00:07:32,050 and then get the finished value once you're done for dad. 116 00:07:32,090 --> 00:07:37,720 I'll comment out the title and put an amount and put and I'll add two new properties which now are final 117 00:07:38,520 --> 00:07:47,320 and add as the title controller, which is created with a value of text editing controller and it's 118 00:07:47,320 --> 00:07:51,670 De Amount controller, which is also a text editing controller. 119 00:07:52,180 --> 00:07:55,690 Text editing controller is a class provided by Flutter. 120 00:07:56,350 --> 00:08:02,290 And you can assign such a controller to your text fields with the help of the controller argument. 121 00:08:02,830 --> 00:08:04,440 So now to the title TextField. 122 00:08:04,570 --> 00:08:13,060 I add my title controller and to the amount TextField here I'll add my amount controller. 123 00:08:13,900 --> 00:08:15,850 Now what do these controllers do? 124 00:08:17,320 --> 00:08:22,010 Flutter automatically connects to controllers with our TextField and these controllers. 125 00:08:22,030 --> 00:08:26,760 Me and listen to the user input and safety user input and they have four here in on prest. 126 00:08:26,800 --> 00:08:32,350 We can then print title controller DOT text to get access to that safe text. 127 00:08:33,190 --> 00:08:41,470 Hence now if I go back and I type something here and I hit done and then at transaction I see test here. 128 00:08:42,070 --> 00:08:46,810 So this is of course a more convenient way because you don't have to manually write a function that 129 00:08:46,810 --> 00:08:49,180 takes a value and just say, sit in a property. 130 00:08:49,450 --> 00:08:55,240 And in addition, as an extra benefit, this is not always a solution because these properties are final 131 00:08:55,240 --> 00:08:58,000 and the heavy lifting of saving stuff is done by flutter. 132 00:08:58,270 --> 00:08:59,380 This is now a solution. 133 00:08:59,530 --> 00:09:01,630 Flutter all likes in a stateless which it. 134 00:09:05,410 --> 00:09:10,750 Nonetheless, the days of us using a stateless widgets were at least of only using stateless widgets 135 00:09:11,260 --> 00:09:17,350 are coming to an end because we will have to change this to a state full widget in order to update our 136 00:09:17,350 --> 00:09:23,320 list of transactions and reflect that change on the user interface, where, of course, for every new 137 00:09:23,320 --> 00:09:26,830 transaction, a new transaction card should be out, put down their. 13875

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