Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,840 --> 00:00:06,060
In the last section, we spoke about how we need to create a global key and somehow reference it or
2
00:00:06,060 --> 00:00:10,980
get it to reference our form state that is created and each time we create a form widget, again, I
3
00:00:10,980 --> 00:00:14,760
know this stuff is kind of heavy duty, kind of complicated, but as soon as we start writing some code,
4
00:00:14,760 --> 00:00:16,890
I think you'll start to get an idea of what's going on.
5
00:00:17,070 --> 00:00:18,200
So let's write some code.
6
00:00:18,960 --> 00:00:24,180
I'm going to begin by looking back over to my code editor and I'm going to find my login screen state
7
00:00:24,180 --> 00:00:24,770
class.
8
00:00:25,500 --> 00:00:31,380
So inside, if you're going to create a new instance variable that's going to store that global key.
9
00:00:32,070 --> 00:00:36,660
So I'm going to make a final variable which remembers just means I cannot reassign this variable.
10
00:00:38,170 --> 00:00:44,260
I'm going to call it form key because it's referencing the form into it, I'm going to assign global
11
00:00:44,260 --> 00:00:49,500
key and then this thing uses that same generic syntax that we use for state up here.
12
00:00:49,930 --> 00:00:57,280
Remember, these generic open closing little brackets are a way to kind of create a constructor or a
13
00:00:57,280 --> 00:01:00,170
class that accepts a type almost like a function.
14
00:01:00,670 --> 00:01:05,650
So we put a type inside of here and that customizes how all the functions inside of it behave, or at
15
00:01:05,650 --> 00:01:07,630
least what different types they expect.
16
00:01:08,540 --> 00:01:15,080
So to the global key, we do not want to reference the form class, we want to reference a class called
17
00:01:15,080 --> 00:01:16,260
Form State.
18
00:01:16,850 --> 00:01:22,010
So for the type here, I'm going to put in form state like so, and then I'm going to put myself in
19
00:01:22,010 --> 00:01:26,300
parentheses to indicate that I want to create an instance of this global key thing.
20
00:01:27,400 --> 00:01:33,940
OK, so this right here is just about the only place we're going to see this form state thing come into
21
00:01:33,940 --> 00:01:34,310
play.
22
00:01:34,420 --> 00:01:39,250
That's why I had to tell you about the existence of this form state, because at some point we had to,
23
00:01:39,250 --> 00:01:41,020
like, write out Farm State right here.
24
00:01:41,260 --> 00:01:45,640
If we just wrote form state, you probably would have been like, Stephen, why are we writing for state
25
00:01:45,640 --> 00:01:46,470
and not just farm?
26
00:01:47,440 --> 00:01:48,670
OK, so this creates the key.
27
00:01:48,970 --> 00:01:54,370
Now, step two is to take this key and associated with the form widget that we are creating.
28
00:01:55,060 --> 00:02:01,810
So on my form widget as an additional named property, I'm going to pass in key and key is going to
29
00:02:01,810 --> 00:02:05,060
be the form key instance variable that we just created.
30
00:02:05,080 --> 00:02:06,940
So I'm going to say form key like so.
31
00:02:07,810 --> 00:02:08,789
And that's pretty much it.
3219
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.