Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,240 --> 00:00:05,750
Our transaction cards don't really look that impressive
2
00:00:05,810 --> 00:00:09,680
and we should certainly change this. To change this,
3
00:00:09,690 --> 00:00:13,630
let's consider how a single transaction might look like here.
4
00:00:13,680 --> 00:00:17,700
So we have our app here and up there,
5
00:00:17,700 --> 00:00:24,320
we have the chart and down there, we have our list of transactions.
6
00:00:24,340 --> 00:00:27,550
Now how should a single transaction look like? Now
7
00:00:27,550 --> 00:00:33,940
obviously, there are dozens of ways of building this and structuring this but one possible way I could
8
00:00:33,940 --> 00:00:41,920
come up with is that for each transaction, we maybe have the price here in a box on the left, almost like
9
00:00:41,920 --> 00:00:42,400
an image,
10
00:00:42,430 --> 00:00:44,110
so our price would be in here,
11
00:00:44,170 --> 00:00:50,920
obviously not a dollar sign but a concrete amount, then next to it, we might have the title, maybe in
12
00:00:50,920 --> 00:00:57,490
a fat bold text and below that, smaller and maybe like light grayish,
13
00:00:57,550 --> 00:01:03,040
we have the date. Not too complex but should be pretty helpful.
14
00:01:03,040 --> 00:01:08,160
Now how could we build this however? How do we build this thing here,
15
00:01:08,170 --> 00:01:16,310
this container? The surrounding piece here, that can probably stay a card, we might want that slight
16
00:01:16,340 --> 00:01:22,790
drop shadow here, we can even increase that with the help of the elevation argument. Inside of that card
17
00:01:22,940 --> 00:01:27,770
and that's really how you should think about building user interfaces in Flutter, what's inside of that
18
00:01:27,770 --> 00:01:28,460
card?
19
00:01:28,460 --> 00:01:32,060
You might say we have three elements in there and that's correct
20
00:01:32,060 --> 00:01:35,530
but how what's actually happening in there?
21
00:01:35,760 --> 00:01:38,940
Well actually, we have two main elements here
22
00:01:39,120 --> 00:01:40,050
sit next to each other,
23
00:01:40,050 --> 00:01:48,240
we have two items here next to each other, so that here should actually be a row in there so that we
24
00:01:48,240 --> 00:01:53,310
have two items next to each other because there is no other way of positioning three items like this
25
00:01:53,310 --> 00:01:59,900
in Flutter other than with a row and in that row, we then have this first item here which could just
26
00:01:59,900 --> 00:02:01,030
be a container,
27
00:02:01,040 --> 00:02:10,380
so let me note this here, that thing here, that purple thing, that's a row, then this thing here might be
28
00:02:10,380 --> 00:02:13,540
a container
29
00:02:13,650 --> 00:02:18,090
and then last but not least, we're running out of colors here,
30
00:02:18,090 --> 00:02:21,610
last but not least if I take that rows color here.
31
00:02:21,630 --> 00:02:24,120
Last but at least, that thing here
32
00:02:24,300 --> 00:02:30,330
so title and date, that of course is another column in there, right?
33
00:02:30,330 --> 00:02:35,730
It's a column inside of our row because we have two items above each other. Columns are not just there
34
00:02:35,730 --> 00:02:41,430
to position items on the overall page but also inside of other widgets, columns do nothing else than
35
00:02:41,580 --> 00:02:46,980
take two or more widgets and position them above each other, no matter how much vertical space there
36
00:02:46,980 --> 00:02:47,310
is.
37
00:02:47,340 --> 00:02:52,950
Here, it's almost no vertical space but still, items above each other means a column. Items next to
38
00:02:52,950 --> 00:02:56,300
each other, like here means a row.
39
00:02:56,430 --> 00:03:00,110
That is how you should think about building user interfaces in Flutter
40
00:03:00,120 --> 00:03:01,740
and that's what I want to build together with you
41
00:03:01,740 --> 00:03:10,220
now. We will build this transaction card together with rows, containers and columns and text and so on. So
42
00:03:10,220 --> 00:03:11,750
back in code,
43
00:03:11,750 --> 00:03:12,740
let's build this.
44
00:03:12,740 --> 00:03:18,800
We have our card and as we just saw when I sketched this, inside that card, we need a row because we
45
00:03:18,800 --> 00:03:20,950
want to have two items next to each other.
46
00:03:21,050 --> 00:03:23,530
So let's replace the text here with a row
47
00:03:23,780 --> 00:03:29,360
and now the row just as a column takes children, two or more widgets which are now placed next to each
48
00:03:29,360 --> 00:03:31,630
other and that's the difference to the column of course,
49
00:03:31,630 --> 00:03:35,390
there items are placed on top of each other or above each other.
50
00:03:35,420 --> 00:03:40,940
Now in that row, we wanted to have that first item which we said could be a container that holds the
51
00:03:40,940 --> 00:03:42,400
price,
52
00:03:42,410 --> 00:03:49,590
so here why don't we add a child which is our text which is tx.price and therefore not price,
53
00:03:49,590 --> 00:03:52,940
tx.amount and therefore the amount of our transaction
54
00:03:52,940 --> 00:03:55,520
and here, I'm getting an error because that's a double
55
00:03:55,610 --> 00:03:59,030
but text actually expects a string here,
56
00:03:59,030 --> 00:04:05,000
so we need to convert the double to a string and we do this by calling to string there. On every double,
57
00:04:05,000 --> 00:04:10,670
you can call to string, on every number you can call to string, actually on every object in Dart,
58
00:04:10,670 --> 00:04:15,500
you can call to string to get a string version of it. Of course for some objects,
59
00:04:15,500 --> 00:04:20,810
that makes more sense, like doubles or numbers in general and for other objects like your own transaction,
60
00:04:20,810 --> 00:04:27,440
to string might just give you some unusable output. Here however we'll get the number as a string which
61
00:04:27,440 --> 00:04:31,260
is really useful and therefore, we already have that container.
62
00:04:31,310 --> 00:04:37,450
Now next to that container in our row here, I want to have that column here,
63
00:04:37,520 --> 00:04:45,690
so that column where we can have the title on top and below that, the date. So let's use column
64
00:04:45,970 --> 00:04:48,630
and then here, again we might have two texts,
65
00:04:48,670 --> 00:04:55,840
so we have the text for the title and then we can copy that to also have the text for the date.
66
00:04:55,900 --> 00:05:03,330
Now date is of type datetime, which also is not a string but we can use to string here to convert this
67
00:05:03,340 --> 00:05:09,080
to a string and see what that gives us. Let's save that and see what we get.
68
00:05:09,490 --> 00:05:14,050
Okay, the rough layout is there, obviously super ugly but we'll get there.
69
00:05:14,050 --> 00:05:15,150
We see the price,
70
00:05:15,160 --> 00:05:20,660
we see the title and below the title, we see the date. The date of course is not nicely formatted,
71
00:05:20,770 --> 00:05:23,560
it's not human readable but we will change that.
7484
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.