Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,420 --> 00:00:04,820
Our application at the moment has one problem.
2
00:00:05,320 --> 00:00:10,370
When I opened that motile sheet and I tried to enter something here, you see that this gets cleared,
3
00:00:10,730 --> 00:00:11,570
the title gets cleared.
4
00:00:11,570 --> 00:00:16,610
As soon as I click into the amount, if I click into the amount into the title now, the amount gets
5
00:00:16,610 --> 00:00:17,000
cleared.
6
00:00:17,630 --> 00:00:18,740
So something's wrong here.
7
00:00:19,160 --> 00:00:22,670
By the way, of course, our amount is also a bit overlapped by the keyboard.
8
00:00:22,700 --> 00:00:27,890
If we enter something into the title and that's something we'll fix later all day, if you would rotate
9
00:00:27,890 --> 00:00:30,830
the device into landscape, you wouldn't really be able to work with that.
10
00:00:30,860 --> 00:00:32,300
But let's take care about this later.
11
00:00:32,480 --> 00:00:37,670
Once we learn how to build more responsive user interfaces for the moment, let's fix that issue of
12
00:00:37,760 --> 00:00:41,600
our data getting lost when we will click into the other fields.
13
00:00:42,320 --> 00:00:43,280
The fix is simple.
14
00:00:43,880 --> 00:00:46,000
You need to change neutrons action.
15
00:00:46,220 --> 00:00:51,590
So does widget, which renders these inputs from a state less into a state full widget, even though
16
00:00:51,590 --> 00:00:57,140
we're not calling said state in here that internally changes something for flutter because the state
17
00:00:57,170 --> 00:01:00,830
object in the end is treated differently then a widget object.
18
00:01:01,460 --> 00:01:04,880
It's basically maintained and not rebuilt as off then easily.
19
00:01:05,330 --> 00:01:08,930
And therefore you should convert neutrons action here to a stateful widget.
20
00:01:09,560 --> 00:01:13,610
And thanks to those refactoring Syntex, that all is done automatically.
21
00:01:13,610 --> 00:01:21,590
And now if you reload your application with that safet, if you now open that again.
22
00:01:21,950 --> 00:01:28,310
Now here we can enter something and now the data is kept and we can add this and see our new transaction
23
00:01:28,310 --> 00:01:30,080
here, which is of course, pretty convenient.
24
00:01:31,130 --> 00:01:37,190
Now, just to clarify and make it clear why we need to make this change to a stateful widget.
25
00:01:37,790 --> 00:01:40,550
It is related to what Flutter does internally.
26
00:01:40,970 --> 00:01:44,030
It re-evaluates widgets from time to time.
27
00:01:44,120 --> 00:01:50,690
For example, if a parent widget changes and I'll dive deeper into how Flattr evaluates your app and
28
00:01:50,690 --> 00:01:54,770
when something is revaluated later in the courts, no worries.
29
00:01:55,190 --> 00:01:56,330
But from time to time, flutter.
30
00:01:56,330 --> 00:01:59,240
Does that ad for a state less widget.
31
00:01:59,750 --> 00:02:06,650
A widget being re-evaluated means that any internally stored data is reset is lost.
32
00:02:06,830 --> 00:02:12,950
That's why we lose our user input in a state less widget, because whenever it is re-evaluated by flutter,
33
00:02:13,010 --> 00:02:18,500
for whatever reason, we lose to state to this kirtley stored in there, we lose our data that's stored
34
00:02:18,500 --> 00:02:18,860
in there.
35
00:02:19,290 --> 00:02:21,740
And for a state full widget, that's different.
36
00:02:21,970 --> 00:02:26,420
Deezer, we have that separate state object, that state class.
37
00:02:26,900 --> 00:02:32,960
And whilst the which it does are also would be re-evaluated by flutter, the state kind of his detached
38
00:02:32,960 --> 00:02:39,430
from this and data stored in that state will not be lost if the widget that belongs to it is reevaluated
39
00:02:39,440 --> 00:02:40,040
by flutter.
40
00:02:40,310 --> 00:02:42,750
So we have a separation of data and the UI.
41
00:02:42,770 --> 00:02:45,710
You could say and therefore we can persist data.
42
00:02:45,920 --> 00:02:51,800
And it's not lost when something changes on the screen or when a flutter decides that it wants to reevaluate
43
00:02:51,830 --> 00:02:52,460
that widget.
44
00:02:52,850 --> 00:02:54,920
That's where our data is then persistent.
45
00:02:54,930 --> 00:02:57,350
And that's why we need a state full widget here.
46
00:02:58,420 --> 00:03:02,200
Now, internally here in new transaction, there is now also one important change.
47
00:03:02,320 --> 00:03:08,770
We still get at transaction as our argument here, and that's inside of our widget, right at transaction
48
00:03:08,770 --> 00:03:12,850
is a property in our widget, not in the state object, but in the widget.
49
00:03:12,970 --> 00:03:17,980
And it needs to be there because we need to define it where we need to accept it on the constructor
50
00:03:17,980 --> 00:03:22,480
of the widget, not on the constructor of the state, because the state is constructed here with the
51
00:03:22,480 --> 00:03:25,180
help of create state and that's inside of the widget.
52
00:03:25,480 --> 00:03:30,820
So to receive something, some data in the widget from outside, which is the case here, we receive
53
00:03:30,880 --> 00:03:33,640
a pointer at the add new transaction function.
54
00:03:34,420 --> 00:03:36,550
We need to accept that on the constructor of the widget.
55
00:03:36,820 --> 00:03:41,860
The problem is that I want to use this function from inside the state object thereafter and not inside
56
00:03:41,860 --> 00:03:42,370
my widget.
57
00:03:42,550 --> 00:03:44,050
And these are two different classes.
58
00:03:44,050 --> 00:03:50,650
Technically, thankfully, Flat-Rate establish that connection and gives us a special property inside
59
00:03:50,650 --> 00:03:51,700
of our estate class.
60
00:03:52,180 --> 00:03:59,320
It gives us this widget property and this refactoring step automatically added it with widget dot.
61
00:03:59,710 --> 00:04:06,760
You can access the properties and methods of your widget class instead of your state class.
62
00:04:07,000 --> 00:04:13,300
So with widget dot at t x, I can access to ads T X property, which has this function reference I get
63
00:04:13,600 --> 00:04:15,700
even though I'm technically in a different class.
64
00:04:16,390 --> 00:04:17,950
That's important widget.
65
00:04:18,200 --> 00:04:20,440
That is a special property we haven't seen before.
66
00:04:20,650 --> 00:04:26,680
It has to be named which ID and it's only available in your state classes and gives you access to the
67
00:04:26,680 --> 00:04:27,460
connected widget.
68
00:04:27,950 --> 00:04:33,670
And with that, we now also fixed that issue off the bottom sheet, clearing our inputs when we type
69
00:04:33,670 --> 00:04:34,030
in there.
70
00:04:34,990 --> 00:04:42,430
Now, one other thing we can do is that when we enter a new transaction here, that we actually all
71
00:04:42,430 --> 00:04:47,110
disclose the bottom sheet as soon as we confirm it and we don't have to close it manually.
72
00:04:47,620 --> 00:04:51,850
And doing that is pretty straightforward here in submit data.
73
00:04:52,360 --> 00:04:59,960
After calling ADT X, you can call Navigator off context, pop.
74
00:05:00,760 --> 00:05:02,120
Now, that's something we haven't seen before.
75
00:05:02,140 --> 00:05:07,300
The navigator is always something I'll have a way closer look at in the navigation section of this course.
76
00:05:07,360 --> 00:05:11,260
It's built into flatter and you can do a lot of awesome stuff here.
77
00:05:11,560 --> 00:05:18,610
We simply use its pop method to basically close to topmost screen that is displayed and that is that
78
00:05:18,610 --> 00:05:19,870
modal sheet if it's opened.
79
00:05:20,410 --> 00:05:23,020
So that closes that motile sheet by popping it off.
80
00:05:23,350 --> 00:05:29,740
And more on that and what it does in detail in a later section of context here is required to get access
81
00:05:30,160 --> 00:05:35,140
to the right navigator or to give the navigator some meta data and context here.
82
00:05:35,170 --> 00:05:42,610
Just like Widget is a special property which is available class white in your state class here, even
83
00:05:42,610 --> 00:05:47,770
though you never defined a property name context, it's made available because we extend state.
84
00:05:48,130 --> 00:05:49,480
So it's basically like widget.
85
00:05:49,540 --> 00:05:51,520
It's a special property that is available.
86
00:05:51,700 --> 00:05:56,230
And that in this case gives you access to the context of your widget widget, gives you access to the
87
00:05:56,230 --> 00:06:01,930
class itself, to its properties and on context, gives you access to the context related to your widget
88
00:06:02,440 --> 00:06:03,640
more or all of that later.
89
00:06:03,760 --> 00:06:10,780
With that, however, we now added the functionality that we can automatically hopes that we can automatically
90
00:06:10,780 --> 00:06:13,990
close our bottom model sheet once we're done.
91
00:06:14,530 --> 00:06:19,450
So if I now add my new shoes here, which let's say cost ninety nine dollars.
92
00:06:19,510 --> 00:06:20,200
Ninety nine.
93
00:06:20,800 --> 00:06:22,670
Now you'll see that also close to molted.
94
00:06:23,410 --> 00:06:28,540
With that, let's continue with our app and let's again turn our heads towards styling.
9844
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.