OndrejKunc / flutter_dynamic_forms

A collection of flutter and dart libraries allowing you to consume complex external forms at runtime.
MIT License
203 stars 59 forks source link

How can get a Dart variable of a JSON/XML form element? #91

Open BrandonRiveraGodines opened 3 years ago

BrandonRiveraGodines commented 3 years ago

I have a JSON file with the form and have textfields, labels, etc. How can I manipulate through dart code? It's possible make an binding xml~dart?

Regards and excuse, it's really neccesary a documentarion.

OndrejKunc commented 3 years ago

When you parse your JSON then the FormManager instance contains the complete tree structure of your form represented as Dart objects. It basically maps all your JSON nodes into the corresponding Dart objects. You can obtain the root of this tree for example by using: FormElement root = FormProvider.of(context).form; So if your root is of type Form and you want to get all children elements, you call (root as Form).children. Normally you don't need to manipulate your tree directly like this, but instead, you can use the element parameter when writing a custom Renderer as described in the Readme.md. Does this answer your question? What is your use case?