Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,930 --> 00:00:07,200
In the last section, we replaced our icon ad with Icon Clear, I'm going to revert this back over to
2
00:00:07,200 --> 00:00:12,090
icons, that ad again, because it's definitely the actual icon we want to show inside of here.
3
00:00:12,120 --> 00:00:13,380
We want that plus icon.
4
00:00:14,330 --> 00:00:16,800
OK, so now our application looks pretty good.
5
00:00:16,850 --> 00:00:21,530
We've got the app at the top and we've got our floating action button at the bottom right hand side.
6
00:00:22,160 --> 00:00:27,440
But there's two little issues I want to point out with our current application, at least as far as
7
00:00:27,440 --> 00:00:34,010
the source code goes right now, all of our app logic or everything that contains information about
8
00:00:34,010 --> 00:00:38,690
what we want to display on the screen is all contained within our main function.
9
00:00:39,350 --> 00:00:43,400
As you might imagine, this is not how we normally design flutter applications.
10
00:00:43,820 --> 00:00:49,910
Traditionally, we'll create separate files inside of our live directory, and each separate file will
11
00:00:49,910 --> 00:00:52,680
contain one widget that you and I will put together.
12
00:00:53,420 --> 00:00:58,280
So I think that we should start thinking about how we might extract all of this logic from the main
13
00:00:58,280 --> 00:01:01,550
function right here into a new separate file.
14
00:01:01,880 --> 00:01:07,400
And that separate file will contain a widget that you and I are going to put together whose sole purpose
15
00:01:07,430 --> 00:01:09,860
is to show all these other widgets.
16
00:01:10,830 --> 00:01:16,100
So to get started, I'm going to first create a new directory inside of my live folder called.
17
00:01:17,200 --> 00:01:19,840
S r. s. short for source.
18
00:01:21,530 --> 00:01:27,320
Then inside the Sarsae directory, I'll make a new file called App Dot Dart.
19
00:01:28,650 --> 00:01:35,460
So inside this file, we're going to create a new custom widget called App Widget, and that app widget
20
00:01:35,460 --> 00:01:40,350
is going to have the sole purpose right now of showing all these other widgets that we just added to
21
00:01:40,350 --> 00:01:41,400
our main function.
22
00:01:42,520 --> 00:01:46,930
Now, this is the first time that we've created our own custom widget up to this point, we've been
23
00:01:47,080 --> 00:01:50,170
reusing all these other widgets that are implemented by Flutter.
24
00:01:50,650 --> 00:01:55,870
So to guide us in putting together our first custom widget, we're going to write out a couple of different
25
00:01:56,110 --> 00:01:56,760
comments.
26
00:01:57,530 --> 00:02:04,300
So the first thing we need to do inside of here is import flutter, helper library, essentially the
27
00:02:04,300 --> 00:02:05,840
same thing that we just did inside of me.
28
00:02:06,070 --> 00:02:10,750
Dart we're going to add an import statement for that material dot dart file.
29
00:02:11,970 --> 00:02:15,690
After that, we're going to create a class.
30
00:02:16,780 --> 00:02:19,630
That will be our custom widget.
31
00:02:20,970 --> 00:02:25,200
Now, this is kind of a two parter, we're going to create a class that's going to be our custom widget
32
00:02:25,200 --> 00:02:29,850
and one special requirement of that class is that we have to extend.
33
00:02:31,610 --> 00:02:39,350
Let's actually kind of write out the full comment here will say This class must extend the state lists
34
00:02:40,130 --> 00:02:42,020
widget based class.
35
00:02:42,680 --> 00:02:44,600
So we'll talk about what that means in just a moment.
36
00:02:44,600 --> 00:02:46,580
But for right now, let's just leave that comment in.
37
00:02:47,680 --> 00:02:54,430
Then inside of our actual class definition, the only requirement that we have is that we must define
38
00:02:54,430 --> 00:03:01,450
a build method that returns the widgets that this.
39
00:03:02,820 --> 00:03:04,140
Widget will show.
40
00:03:05,360 --> 00:03:11,420
OK, so that's our three big items, let's get started right now with item number one at the top because
41
00:03:11,420 --> 00:03:13,510
we pretty much already know how to take care of this one.
42
00:03:14,240 --> 00:03:20,180
So underneath the first comment, I'm going to add in my import statement now, we're importing a package.
43
00:03:20,180 --> 00:03:22,040
We're importing a third party library.
44
00:03:22,430 --> 00:03:27,590
So we're going to write out the word package that will write out the library that we're trying to import,
45
00:03:27,890 --> 00:03:28,670
which is flutter.
46
00:03:29,120 --> 00:03:34,670
And then the name of the file that we want to import, which is material dot dart.
47
00:03:36,510 --> 00:03:37,710
OK, so that was the easy part.
48
00:03:38,160 --> 00:03:39,600
Now let's take a quick pause right here.
49
00:03:39,810 --> 00:03:45,180
We're going to come back the next section and we'll have a quick discussion on what all this extending
50
00:03:45,180 --> 00:03:47,550
the stateless widget based class means.
51
00:03:47,580 --> 00:03:49,530
So quick break and I'll see you in just a minute.
5227
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.