Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Let's now also use the selected date and we already have the submit data method which is triggered
when we try to add the transaction. There right now, we're validating that we have a title and an amount
and if either of the two is missing, we return which means we don't submit the data.
Now I want to add a third condition which when it is false will also lead to this not being submitted
and that is of course that selected date is equal to null,
so it's not set.
If that is not set, then I also want to quit.
So if either of these three conditions is met, if we have no title, if the amount is below zero or equal
to zero or if we have no selected date, then we will return
and as an addition to avoid errors, if you don't even have an amount entered, so if you hit add transaction
here with nothing entered where you get an error right now, you can also add an initial check here and
check if _amountController.text is empty,
in that case this here would always fail,
then you can also return.
Now you can still fail if you enter some text that is not passable into the amount controller but that's
a case we can ignore for now, at least we now avoid errors because we try to submit an empty form
but back to submitting our date. In the end, the goal has to be that we pass our selected date here, the
datetime object to addTx, so to our add transaction function. The add transaction function in the end is of
course defined in main.dart, there we have add new transaction and at the moment, we're not expecting
a date here.
Of course we can change this,
we can accept a third argument which is of type datetime which is the chosen date and the chosen
date should now be used here instead of datetime
now as a date for the transaction and that should already be all we need to do.
This should allow us to pick a date and use it in the create a transaction.
So if I now add a title here, new shoes and a value of let's say 69.99, then at
the moment I also can't get to my date picker without closing the keyboard,
so we'll have to take care about this soon.
For now let's close the keyboard and now choose a date and
let's say yesterday. If I now add the transaction, that's looking good, it was added to yesterday not today
and now let's try another transaction, groceries for 15.86
let's say. Close that, choose a date and let's say that was on Sunday, and indeed that's added here
on Sunday and you see it only makes up a fraction of our total spendings.
Now the fact that we can't really get to our date picker here without manually closing the keyboard
is something we should also take care of
of course. For the moment, it's however something we can live with
and later, we'll learn about a technique or about a certain feature of Flutter that helps us with fixing
this problem here as well.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.