Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,310 --> 00:00:09,120
Now with our stateful widget added, it's important to have a brief first look. I'll later to have
2
00:00:09,120 --> 00:00:15,450
a more detailed look but a brief first look at what Flutter actually does when set state is executed
3
00:00:15,450 --> 00:00:22,860
here. Set state is a function that forces Flutter to re-render the user interface, however not the entire
4
00:00:22,860 --> 00:00:24,950
user interface of the entire app,
5
00:00:25,020 --> 00:00:31,350
instead what set state does in the end is it calls build again of this widget where you call set
6
00:00:31,350 --> 00:00:32,410
state.
7
00:00:32,550 --> 00:00:36,550
Now in our case, that is almost the entire app, MyApp,
8
00:00:36,540 --> 00:00:40,300
this widget here with this build method that is basically our entire app
9
00:00:40,470 --> 00:00:47,160
but later in this course, we'll have bigger applications with more widgets where we split that into more
10
00:00:47,160 --> 00:00:53,160
custom widgets and therefore, it will really make a difference if you update the entire app or just that
11
00:00:53,190 --> 00:00:54,460
widget with set state,
12
00:00:54,570 --> 00:00:58,350
so set state updates this widget by calling its build method again.
13
00:00:58,550 --> 00:01:02,490
Now the build method goes ahead and rebuilds this widget tree,
14
00:01:02,520 --> 00:01:05,610
it basically goes through all these instructions again.
15
00:01:05,670 --> 00:01:10,260
Now that might sound very inefficient because the majority of this user interface didn't change right,
16
00:01:10,260 --> 00:01:11,610
all the buttons are still the same,
17
00:01:11,610 --> 00:01:12,960
the appBar is the same,
18
00:01:12,960 --> 00:01:15,830
only this text changed and therefore Flutter,
19
00:01:15,840 --> 00:01:22,440
no worries, is pretty efficient about that. Internally, it has a lot of mechanism to go through that build
20
00:01:22,440 --> 00:01:28,500
method again but to not really render the entire UI again, so it does not redraw every pixel again.
21
00:01:29,100 --> 00:01:36,120
In the end, it just has its tools and its mechanisms to find out what changed on the screen and what
22
00:01:36,120 --> 00:01:43,110
needs to be redrawn and therefore it will find out that text here changed, that this widget changed because
23
00:01:43,110 --> 00:01:47,970
the text we passed to it changed and it will only update this text here
24
00:01:47,970 --> 00:01:55,260
in the end. Now again, I'll dive deeper into how that works and how we can find out what Flutter changed
25
00:01:55,260 --> 00:01:57,830
and so on, I'll dive into that throughout the course
26
00:01:57,830 --> 00:02:03,030
once we are a bit more proficient with Flutter, it's just a brief first look which I wanted to give you
27
00:02:03,030 --> 00:02:09,060
at this point, that build is getting called when you call set state and that is why you see the change
28
00:02:09,090 --> 00:02:14,250
then and that is also why you didn't see anything without set state because then you changed the data
29
00:02:14,250 --> 00:02:20,400
which is nice but Flutter never executed build again and therefore this widget tree never got rebuilt
30
00:02:20,550 --> 00:02:25,440
and therefore this text with the updated text never made it onto what the user sees.
3471
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.