Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,220 --> 00:00:07,620
Let's now also use the selected date and we already have the submit data method which is triggered
2
00:00:07,710 --> 00:00:13,950
when we try to add the transaction. There right now, we're validating that we have a title and an amount
3
00:00:13,950 --> 00:00:18,720
and if either of the two is missing, we return which means we don't submit the data.
4
00:00:18,720 --> 00:00:24,720
Now I want to add a third condition which when it is false will also lead to this not being submitted
5
00:00:24,720 --> 00:00:29,550
and that is of course that selected date is equal to null,
6
00:00:29,580 --> 00:00:30,550
so it's not set.
7
00:00:30,570 --> 00:00:33,030
If that is not set, then I also want to quit.
8
00:00:33,480 --> 00:00:39,660
So if either of these three conditions is met, if we have no title, if the amount is below zero or equal
9
00:00:39,660 --> 00:00:44,400
to zero or if we have no selected date, then we will return
10
00:00:44,700 --> 00:00:52,680
and as an addition to avoid errors, if you don't even have an amount entered, so if you hit add transaction
11
00:00:52,680 --> 00:00:58,170
here with nothing entered where you get an error right now, you can also add an initial check here and
12
00:00:58,170 --> 00:01:03,760
check if _amountController.text is empty,
13
00:01:03,770 --> 00:01:06,440
in that case this here would always fail,
14
00:01:06,500 --> 00:01:07,960
then you can also return.
15
00:01:07,970 --> 00:01:13,550
Now you can still fail if you enter some text that is not passable into the amount controller but that's
16
00:01:13,550 --> 00:01:19,010
a case we can ignore for now, at least we now avoid errors because we try to submit an empty form
17
00:01:19,280 --> 00:01:25,640
but back to submitting our date. In the end, the goal has to be that we pass our selected date here, the
18
00:01:25,640 --> 00:01:33,440
datetime object to addTx, so to our add transaction function. The add transaction function in the end is of
19
00:01:33,440 --> 00:01:39,110
course defined in main.dart, there we have add new transaction and at the moment, we're not expecting
20
00:01:39,110 --> 00:01:40,150
a date here.
21
00:01:40,160 --> 00:01:41,520
Of course we can change this,
22
00:01:41,600 --> 00:01:47,120
we can accept a third argument which is of type datetime which is the chosen date and the chosen
23
00:01:47,120 --> 00:01:49,520
date should now be used here instead of datetime
24
00:01:49,520 --> 00:01:54,810
now as a date for the transaction and that should already be all we need to do.
25
00:01:54,860 --> 00:01:59,090
This should allow us to pick a date and use it in the create a transaction.
26
00:01:59,660 --> 00:02:08,900
So if I now add a title here, new shoes and a value of let's say 69.99, then at
27
00:02:08,900 --> 00:02:12,560
the moment I also can't get to my date picker without closing the keyboard,
28
00:02:12,560 --> 00:02:14,710
so we'll have to take care about this soon.
29
00:02:14,720 --> 00:02:16,840
For now let's close the keyboard and now choose a date and
30
00:02:16,880 --> 00:02:23,320
let's say yesterday. If I now add the transaction, that's looking good, it was added to yesterday not today
31
00:02:23,320 --> 00:02:29,930
and now let's try another transaction, groceries for 15.86
32
00:02:29,930 --> 00:02:39,770
let's say. Close that, choose a date and let's say that was on Sunday, and indeed that's added here
33
00:02:39,980 --> 00:02:44,950
on Sunday and you see it only makes up a fraction of our total spendings.
34
00:02:45,020 --> 00:02:50,840
Now the fact that we can't really get to our date picker here without manually closing the keyboard
35
00:02:51,110 --> 00:02:52,730
is something we should also take care of
36
00:02:52,730 --> 00:02:56,430
of course. For the moment, it's however something we can live with
37
00:02:56,510 --> 00:03:02,960
and later, we'll learn about a technique or about a certain feature of Flutter that helps us with fixing
38
00:03:02,960 --> 00:03:04,430
this problem here as well.
4235
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.