I'm making a simple TODO app in Flutter. Next to each item I have an "Edit" icon which opens an AlertDialog
with pre-filled description and amount of that item. When I click outside of the dialog, it is dismissed, as expected. For this form I use two String variables called description
and amount
, as well as two controllers called descriptionController
and amountController
.
I also have the "Add" button, which opens a similar alert dialog with a similar form, in which I use same string variables and controllers.
The problem arises in the following scenario: - I click the "Edit" button for a certain item. The dialog appears with pre-filled fields. - I dismiss the dialog by clicking outside. - I click the "New" button. The dialog appears, but instead of empty fields, I still see the values from the item that I was editing before.
One of the solutions would of course be to use separate controllers. But I would like to know if there is a possibility to detect that the dialog is dismissed by clicking outside and to perform a certain action (clear the controllers).
Thanks.