How to reset the dropdown button in flutter? - flutter

I have a dropdown button which works fine when I visit the page(having the button) first time but whenever i revisit the page containing the dropdown button, the previously selected value appears rather than the hint text which i want to appear every time the page is visited.

Dropdown button has a property value where we specify our variable to get the selected value. Before moving to the next screen you can set back the default value to it and it should work.

Related

How to change the Form according to the item selected in the drop Down menu in Flutter

I have created I method which is showing a dialog and I called it with timer.run() method in order to show the dialog at the start of the screen automatically in which i have created a form (the code snippet is attached in the photos) and the form contains drop-down menu with two items(check and bank) now i want to make the UI as dynamic whenever the user selects the Bank option in the drop-down menu a new drop-down menu is displayed to him otherwise an empty container will be displayed to him.
Solutions I tried
created i variable which holds true if the item selected is bank otherwise false and used it as a condition to either show the 2nd drop-down or not.
Make the variable global but it also didn't worked.
created a function which i called with the variable to return either drop-down or empty container but it also didn't worked.
Created the bank selected variable in other class and access it with provider package but it also didn't worked for me.
The source code is also available at Github-Repo
Thanks all someone at linkedin helped me with the solution. which is
We have to wrap the AlertDialog with StatefulBuilder and have to call setState when option is selected then it will work.

Dropdown menu View in Flutter

I have a dropdown in my app like this.
at beginning i am showing "Choose Filters" as the dropdown hint, once any of the item in dropdown in selected and there is a button as + icon once pressed I am doing further operations.
If an option is selected in dropdown its visible in the app, what I want to do is after selecting an option if clicks on that + icon I want instead of that selected dropdown value display the hint i.e "Choose Filters" . Is there any way to that please let me know.Thanks!
If you want the DropdownButton to show the hint again, you need to set it's selected value to null. So the variable you are setting on the property value of the DropdownButton should be set to null.

Why does clicking on a TextFormField trigger didUpdateWidget()?

I've ran into a problem. In one section of my page I have a date with today's date. If the user clicks on an arrow to the right it goes forward a date and if they person clicks an arrow to the left it goes back a date. On the arrow buttons I am using setState. The date changes perfectly fine.
I also have a form below on a separate card. To each textFormField I h ave a controller set up. I had to set these up because initialvalue: only gets called once so the fields were never changing with the date.
Anyway the fields now change with the date and it is correct. But the moment I click on the form, The top widget date shoots back to the initial value it was at?
I checked this by setting up a didUpdateWidget override and this is firing every time I click on the form field??? Why is this happening. I am not updating anything yet.
When I used a controller for the date value displayed between the two arrows it doesn't change but when I hit submit the value it's supposed to be assigned to is the wrong (very first date that appears). So it seems like when didUpdate fires it is setting that field which I have set in my extends StatefulWidget class{}.
EDIT: Wow typing that last sentence made me realize I needed to set the value in my bottom class that extends State<>. I was using it with widget.activeDay.
I guess I'm still curious as to why this is happening with the text form field though?
Clicking on a text-field opens the keyboard.
This changes the screen dimensions and leads to MaterialApp rebuilding the route.
The route rebuilding ultimately calls didUpdateWidget on that specific widget.

Get value from session and display in an item (date picker) in Oracle APEX

Refer to Figure 1, after user selected Start Date and End Date, then click on the Search button. When the Search button is clicked, the action submit page will be performed. But after the page is refresh, the value in the date picker is empty and the value is stored in the session.
My questions are:
How to get a value from session and display on an item
How to keep the value of dates in date pickers.
By default, value in the item have to be saved after submit. If your item loses its value after button click, then you have made something to that. There is a number of ways to do it, sometimes not obvious, so first check:
Item's properties, Source tab
Processes on the page - it could be a process with type Clear Session State
After that, try to remember all what you did after creating items. Create new page from scratch, add desired items and button with default properties, then make changes in properties one by one and check every change.
In the branch for that submit action, make sure you have entered "set items". Set the item "P20_START_DATE" with the value "&P20_START_DATE'".
In Apex 5, go to the branch, click on "Target" in the behaviour session and set the values there.
Summary, the way to maintain a value in an item after page submit is
Click on the item
Navigate to Source tab
Set Type to item
Set the Item to the Item you want to keep the value

Liferay Autofield with DatePicker

I have a aui form with Liferay.Autofields enabled.
The fields that I am duplicating with Autofield has a button and a textfield. The button click will trigger the datepicker and the selected value should be stored in the textfield.
And, when I click the "PLUS" button provided by Autofield, the fields are duplicated.
First, I need to know how I can bind the trigger event of all buttons to the datepicker. I know to do this for a single button. But since we are using autofield, I need to give the ID of the button with the index. Can anyone suggest how to bind the trigger event in my scenario
Second, once I click the date picker button, I should be able to get index of the Autofield row in which I have clicked, so that I can update my textfield