Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DropdownSearch value resets whole changing focus #51

Closed
Ayan4044 opened this issue Oct 22, 2020 · 8 comments
Closed

DropdownSearch value resets whole changing focus #51

Ayan4044 opened this issue Oct 22, 2020 · 8 comments

Comments

@Ayan4044
Copy link

I was trying to use the Widget in a row and also in a dynamic widget, the problem is that as change the focus to other input widgets the value resets. In case you use selecteditem attribute then it resets to the initial value.

Row( children: [ Flexible( flex: 1, child: Padding( padding: EdgeInsets.only(left: 5), child: TextFormField( controller: _descriptionController, onChanged: (v) => _UpdateFormState.descriotiondata[widget.index] = v, validator: (v) { if (v .trim() .isEmpty) return 'Please enter Study Description'; return null; }, style: TextStyle(color: Colors.blue), decoration: InputDecoration( counterText: '', filled: true, fillColor: Color(0xFFF5F5F5), labelText: "Description", labelStyle: TextStyle(color: Color(0xFF45B4FF)), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.blueAccent, width: 1.0), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.blueGrey, width: 1.0), ), ), ), ), /* TextFormField( controller: _descriptionController, onChanged: (v) { _UpdateFormState.descriotiondata[widget.index] = v; }, decoration: InputDecoration( hintText: 'Study Description' ), validator: (v){ if(v.trim().isEmpty) return 'Please enter Study Description'; return null; }, ),*/ ), SizedBox(width: 10), Flexible( flex: 2, child: DropdownSearch<StudyName>( mode: Mode.BOTTOM_SHEET, isFilteredOnline: true, showClearButton: true, showSearchBox: true, items: studyNamemodel, itemAsString: (StudyName u) => u.studyName, onChanged: (StudyName data) { print(data.studyName); _UpdateFormState.dropdowndata[widget.index] = data.studyName; //FocusScope.of(context).nextFocus(); }, maxHeight: 300, onFind: (String filter) => getData(filter), label: "Study Name", ), ), ], );

For further reference, I had already posted this on stackoverflow here is the link

salim-lachdhaf added a commit that referenced this issue Oct 30, 2020
Invoke the dropdown programmatically
change dropdownSearch selected value programmatically
fix issue #25
fix issue #36
fix issue #51
fix issue #55
@salim-lachdhaf
Copy link
Owner

check v 0.4.6, this should be fixed.

@Ayan4044
Copy link
Author

Ayan4044 commented Nov 2, 2020

Okay will try out

@ZafarAhmad74
Copy link

I tried but this problem still there secondly If you save data and restart the app how to update the widget to that state

@ZafarAhmad74
Copy link

Let me know if I want to reopen the issue or create a new one

@salim-lachdhaf
Copy link
Owner

salim-lachdhaf commented Nov 4, 2020

Check my anwser in stackoverflow, let me know if it works for you.
And take a look to this it could help
#56

I'm waiting for your feedback

Edit:
In your code you are even not using selectedItem in your code !
Check plugin example please.

@ZafarAhmad74
Copy link

ZafarAhmad74 commented Nov 4, 2020 via email

@ZafarAhmad74
Copy link

Thank you very much for such a quick reply and I apologize that I didn't look at the link for Stackoverflow and commented, however, I found it later the both of my questions are answered.

Thanks again for helping.

Regards,
Zafar

@Ayan4044
Copy link
Author

Ayan4044 commented Nov 5, 2020

Hi I have tested it, its working thanks for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants