peiffer-innovations / json_dynamic_widget

MIT License
226 stars 67 forks source link

Issue with dropdown_button_form_field #289

Closed naveen715 closed 5 months ago

naveen715 commented 5 months ago

{ "type": "set_value", "args": { "values": { "index": ["abc","pqr","stu"] }, "child":{ "type": "expanded", "args": { "child": { "type": "dropdown_button_form_field", "listen": [ "index" ], "args": { "decoration": { "labelText": "Select Island" }, "items":"${index}", "validators": [ { "type": "required" } ] } } } } } }

creating a dropdown with dynamic items throws errror

The following NoSuchMethodError was thrown building _JsonWidgetStateful-<'json_widget_stateful.5f9aaa94-78b3-4c52-beb4-e66ea587a918'>: Class 'String' has no instance method 'forEach'. Receiver: "${index}" Tried calling: forEach(Closure: (dynamic, dynamic) => Null)

The relevant error-causing widget was: _JsonWidgetStateful-[<'json_widget_stateful.5f9aaa94-78b3-4c52-beb4-e66ea587a918'>] _JsonWidgetStateful:file:///C:/Users/nkt88/AppData/Local/Pub/Cache/hosted/pub.dev/json_dynamic_widget-7.0.6+5/lib/src/builders/json_widget_builder.dart:62 :16

I have pasted the entire error log for your reference if you can please provide a sample of dropdown_button_form_field using set value or dynamically getting data for items. @crisperit @jpeiffer

crisperit commented 5 months ago

Yeah it seems that JsonDynamicBuilder and JsonDropdownButtonFormFieldBuilder are not generated via the builders and they are not porcessing args well

@jpeiffer Can you give your approval under the fix?

jpeiffer commented 5 months ago

For your PR? Just merged it.