set default select item on FormBuilderSearchableDropdown [flutter_form_builder]

359 views
Skip to first unread message

You Sour

unread,
Jan 14, 2021, 4:05:07 AM1/14/21
to Flutter Development (flutter-dev)

hi , i'm using FormBuilderSearchableDropdown everything work perfectly , but i got a small problem on my Edit Form i want to set a default select item but i don't know how to set it . data list i get from my backend service look like this

Data :

[ {'label':'Apple', value: 00001}, {'label':'Book', value: 00002} ]

Backend Method

Screen Shot 2021-01-14 at 3.59.34 PM.png

Edit from

Screen Shot 2021-01-14 at 4.00.00 PM.png

can you show me how to set it ?
thank in advance :)

Suzuki Tomohiro

unread,
Jan 14, 2021, 7:56:59 AM1/14/21
to You Sour, Flutter Development (flutter-dev)
Can you share URL of the API documentation of FormBuilderSearchableDropdown?

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/acccb00c-0c15-44ce-9d4d-338de0386851n%40googlegroups.com.

You Sour

unread,
Jan 14, 2021, 7:56:48 PM1/14/21
to Flutter Development (flutter-dev)
sorry ,i don't understand , what you want :/

Suzuki Tomohiro

unread,
Jan 14, 2021, 8:58:14 PM1/14/21
to Flutter Development (flutter-dev)
I want to see the document you were reading when you tried to use FormBuilderSearchableDropdown. Not a blog post but its official documentation.

You Sour

unread,
Jan 14, 2021, 9:19:35 PM1/14/21
to Flutter Development (flutter-dev)
in fact FormBuilderSearchableDropdown is a widget of flutter_form_builder package and it depend on 
dropdown_search 0.4.8  package so that is where i can see the document because in flutter_form_builder package i don't see any document how to use it     

Suzuki Tomohiro

unread,
Jan 14, 2021, 11:09:51 PM1/14/21
to Flutter Development (flutter-dev)
Nice. DropdownSearch has selectedItem parameter. Does that work for you?
You might need to figure out how FormBuilderSearchableDropdown touches the parameter.

You Sour

unread,
Jan 15, 2021, 8:30:58 AM1/15/21
to Flutter Development (flutter-dev)
i think it might work , but the problem i don't know how to set it , because when i insert data to database is value not label. label just show for user only , you can see my data example backend service  [ {'label':'Apple', value: 00001}, {'label':'Book', value: 00002} ]  

Suzuki Tomohiro

unread,
Jan 15, 2021, 8:45:27 AM1/15/21
to Flutter Development (flutter-dev)
You must have the conversion from value to label. Use that conversion.

You Sour

unread,
Jan 15, 2021, 9:36:05 AM1/15/21
to Flutter Development (flutter-dev)
can you show me some example code or any doc ?
and here the work flow i want
flow.jpg 

Suzuki Tomohiro

unread,
Jan 15, 2021, 10:09:03 AM1/15/21
to Flutter Development (flutter-dev)
No I don’t have any example or doc (I don’t use the widget)

What is the widget that you think should take a default value?  (and share the URL of the API document of the widget)

We know that DropdownSearch takes selectedItem parameter. Are you using other widgets?

You Sour

unread,
Jan 15, 2021, 8:01:03 PM1/15/21
to Flutter Development (flutter-dev)
you can see the workflow i post , on form update you will understand what i want  

Suzuki Tomohiro

unread,
Jan 15, 2021, 8:04:26 PM1/15/21
to Flutter Development (flutter-dev)
I’m afraid that I still don’t know what widget you want to pass a default value.

You Sour

unread,
Jan 15, 2021, 8:17:46 PM1/15/21
to Flutter Development (flutter-dev)
FormBuilderSearchableDropdown widget

Suzuki Tomohiro

unread,
Jan 15, 2021, 8:30:22 PM1/15/21
to Flutter Development (flutter-dev)
The document says all widget (including FormBuilderSearchableDropdown) has  initialValue property.

In order to create an input field in the form, along with the label, and any applicable validation, there are several attributes that are supported by all types of inputs namely:
> ...
initialValue

Does this set initial value?


You Sour

unread,
Jan 15, 2021, 9:40:20 PM1/15/21
to Flutter Development (flutter-dev)
it doesn't work :(

Suzuki Tomohiro

unread,
Jan 15, 2021, 10:14:33 PM1/15/21
to Flutter Development (flutter-dev)
Do you think that’s because (a) the widget has a bug, or (b) your use case has a special requirement?
(a-or-b question)

You Sour

unread,
Jan 15, 2021, 10:37:27 PM1/15/21
to Flutter Development (flutter-dev)
B

Suzuki Tomohiro

unread,
Jan 15, 2021, 11:26:24 PM1/15/21
to Flutter Development (flutter-dev)
1. Good. Would you be willing to explain why your use case is special? From the right of the diagram, it seems to me that your case is a common one where you get data from data from a server to populate the dropdown menu.

2. Would you try this experiment; without using data from the server, would you confirm that you can use the initialValue property of FormBuilderSearchableDropdown?



You Sour

unread,
Jan 17, 2021, 9:23:31 AM1/17/21
to Flutter Development (flutter-dev)
even though i get list data without using data from the serve , it can't  initialValue   

Suzuki Tomohiro

unread,
Jan 17, 2021, 9:32:40 AM1/17/21
to You Sour, Flutter Development (flutter-dev)
even though i get list data without using data from the serve , it can't  initialValue   

Good. Then you just need to learn how to use initialValue of the FormBuilderSearchableDropdown. Would you run the example project to see how the widget works?


You Sour

unread,
Jan 18, 2021, 3:34:45 AM1/18/21
to Flutter Development (flutter-dev)
after a few days i stuck with this problem now it works, selectedItem isn't work for me but initialValue it works perfectly with FutureBuilder , thank you so much for your time  😄

Suzuki Tomohiro

unread,
Jan 18, 2021, 9:13:32 AM1/18/21
to Flutter Development (flutter-dev)
You're welcome. Glad to hear it worked. In general, popular Flutter plugins have nice documents and examples. 

Reply all
Reply to author
Forward
0 new messages