Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,250 --> 00:00:09,120
Before we continue working on the app itself, let me play around with the column a bit because right
2
00:00:09,120 --> 00:00:15,810
now, our two cards here, this blue card and the white card below there, are clearly positioned inside of
3
00:00:15,810 --> 00:00:16,320
a column,
4
00:00:16,320 --> 00:00:21,750
that is why we can have them above each other and we can also see that they seem to be centered.
5
00:00:22,050 --> 00:00:24,930
The card with the chart in it takes the full width,
6
00:00:24,960 --> 00:00:31,170
so here we don't really see the centering effect but we can clearly see it on our list of tx card.
7
00:00:31,170 --> 00:00:35,120
It's in the middle horizontally, not vertically
8
00:00:35,400 --> 00:00:38,010
and that is the default behavior indeed of a column.
9
00:00:38,010 --> 00:00:42,330
Now let's go to the column widget and let's see what we can actually configure there.
10
00:00:42,330 --> 00:00:47,360
Here, you see you have a cross axis alignment and a main axis alignment
11
00:00:47,520 --> 00:00:54,780
and these are the two core configuration options which you have to configure how your column behaves
12
00:00:54,780 --> 00:01:00,830
and you have the exact same options on a row by the way. Column and row are core widgets in Flutter,
13
00:01:00,840 --> 00:01:04,650
they allow you to position items next to each other or above each other,
14
00:01:04,680 --> 00:01:09,980
column allows you to position items vertically, row horizontally.
15
00:01:09,990 --> 00:01:15,360
Now you do that positioning with the help of the so-called main axis and cross axis
16
00:01:15,440 --> 00:01:20,730
and for a column, the main axis by default is from top to bottom, cross axis is from left to right.
17
00:01:20,730 --> 00:01:26,730
So with these two configuration options, you can define how the items should be positioned inside of the
18
00:01:26,730 --> 00:01:32,830
column, both regarding the vertical direction and the horizontal direction. For row it's the opposite,
19
00:01:32,830 --> 00:01:37,560
there the main axis is left to right and the cross axis is top to bottom
20
00:01:37,560 --> 00:01:43,890
and with these properties of column and row which you can set through their constructors, you have a broad
21
00:01:43,890 --> 00:01:48,690
variety of options of how you want to position the items that you have inside your column or row.
22
00:01:49,350 --> 00:01:54,720
Let's see an example, here's our column and now let's set the main axis alignment here too
23
00:01:54,940 --> 00:01:57,750
and now what does this need here, which type of value?
24
00:01:57,750 --> 00:02:00,210
It needs a main axis alignment value.
25
00:02:00,210 --> 00:02:03,810
So let's enter main axis alignment and let the IDE help you.
26
00:02:03,810 --> 00:02:05,700
You should get a couple of suggestions here
27
00:02:05,730 --> 00:02:12,820
and as you see, there are a couple of static fields or to be precise, that actually now is a enum.
28
00:02:13,020 --> 00:02:17,730
You know enum is that thing where you actually just have a couple of different options which are numbers
29
00:02:17,790 --> 00:02:23,250
with human readable labels and then these numbers are interpreted internally, in this case by the column
30
00:02:23,250 --> 00:02:24,180
widget.
31
00:02:24,180 --> 00:02:25,920
So here we can set this to center, end
32
00:02:26,020 --> 00:02:27,290
and so on.
33
00:02:27,330 --> 00:02:29,820
Now the default actually is start,
34
00:02:29,820 --> 00:02:32,250
let's see what happens if I set this to end.
35
00:02:32,370 --> 00:02:33,080
If we do that,
36
00:02:33,090 --> 00:02:37,860
now you see the items are pushed all the way to the end of the column and therefore to the end of the
37
00:02:37,860 --> 00:02:39,270
screen,
38
00:02:39,290 --> 00:02:41,150
that's what I meant with the default will start,
39
00:02:41,150 --> 00:02:44,130
that's why they were at the beginning of it initially.
40
00:02:44,180 --> 00:02:52,320
Now you can also set this to center and now unsurprisingly, they are in the middle of the screen.
41
00:02:52,340 --> 00:02:56,620
Now sometimes, you always want to have some space between these items and therefore, you have SpaceAround
42
00:02:56,620 --> 00:03:03,370
and SpaceBetween and SpaceEvenly. With SpaceBetween, the first card is right at the top and the second
43
00:03:03,370 --> 00:03:08,530
card is at the bottom, so the empty space in a column which is always there, because a column by default
44
00:03:08,530 --> 00:03:10,210
takes all the height it can get,
45
00:03:10,210 --> 00:03:12,980
it has double infinity as a height value
46
00:03:13,150 --> 00:03:18,190
so to say, because that column takes all the height it can get and therefore the full device height
47
00:03:18,310 --> 00:03:20,470
minus the app bar, because of that
48
00:03:20,470 --> 00:03:27,670
now the whitespace with this setting is between the items. With SpaceAround, it's a bit different, there
49
00:03:27,970 --> 00:03:30,010
the empty space is around the items,
50
00:03:30,010 --> 00:03:34,370
so we have the equal amount of empty space in front and after each item.
51
00:03:34,750 --> 00:03:40,330
These are very helpful settings which you can use on both columns and rows to position items along the
52
00:03:40,330 --> 00:03:41,190
main axis,
53
00:03:41,290 --> 00:03:45,340
which just because it's important is top to bottom
54
00:03:45,340 --> 00:03:52,510
on a column and left to right in a row. Now besides the main axis, you also have the cross axis where you
55
00:03:52,510 --> 00:03:56,250
can position items. Now to see an effect of that,
56
00:03:56,260 --> 00:04:02,720
let's first of all go to the second card and give that a color of let's say colors.red so that
57
00:04:02,720 --> 00:04:06,570
we can see that second item just as well as the first one.
58
00:04:06,590 --> 00:04:12,050
Now here for cross axis alignment, you use cross axis alignment which also is an enum
59
00:04:12,050 --> 00:04:14,030
and here you've got a couple of different values.
60
00:04:14,120 --> 00:04:16,970
You also have end and start, let's see what these do,
61
00:04:16,970 --> 00:04:18,740
let's set it to start
62
00:04:18,740 --> 00:04:24,140
and now you see, the one here which takes the full width will never change because the cross axis for
63
00:04:24,140 --> 00:04:25,550
a column is left to right
64
00:04:25,580 --> 00:04:31,430
and since this takes the full width left to right, we can't position it but the smaller card can be positioned
65
00:04:31,660 --> 00:04:37,250
and with a cross axis alignment of start, is all the way on the left because the cross axis starts on
66
00:04:37,250 --> 00:04:39,710
the left by default.
67
00:04:39,710 --> 00:04:44,840
Of course unsurprisingly if we set this to end, we therefore push the item all the way to the end of
68
00:04:44,840 --> 00:04:51,350
our column, all the way to the right here because cross axis is left to right. Now other values we have
69
00:04:51,350 --> 00:04:57,440
here for example are center which is the default, where this is in the middle horizontally and as you
70
00:04:57,440 --> 00:05:04,670
see, also for example stretch. If you use stretch, now this red card also takes the full available
71
00:05:04,670 --> 00:05:11,930
width and here again we have that scenario where card normally would take the width of its child but
72
00:05:11,930 --> 00:05:18,310
now the parent of the card, which of course is our column here for the second card, the parent sets a
73
00:05:18,500 --> 00:05:23,600
clearly defined width, in this case it sets a width of take all the width you can get and now the
74
00:05:23,600 --> 00:05:29,060
card follows that parent width. Again, something where you can always experiment with to get a feeling
75
00:05:29,060 --> 00:05:36,380
for how that behaves. And main axis and cross axis alignment on columns are super important, the same for
76
00:05:36,380 --> 00:05:42,740
rows of course because column and rows are so important, crucial core widgets which help you to position
77
00:05:42,830 --> 00:05:49,010
and align the items or the widgets you have on your screen. That's why we had this little excursion here,
78
00:05:49,010 --> 00:05:55,160
this little look at how we can work with column and main axis and cross axis alignment. Of course we
79
00:05:55,160 --> 00:06:00,050
don't really need this alignment and this look we have here, we'll go back to our application now but
80
00:06:00,050 --> 00:06:06,110
it's super important to take that with you that you can align items in a column and also in a row with
81
00:06:06,110 --> 00:06:08,930
the help of main axis alignment and cross axis alignment.
9142
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.