OndrejKunc / flutter_dynamic_forms

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

server #28

Open joeblew99 opened 5 years ago

joeblew99 commented 5 years ago

Could you extend one of the examples to use a server for getting the xml and posting it back ?

OndrejKunc commented 5 years ago

Hi, thanks for opening the issue.

Can you please explain why do you need the real server? To get the xml you just need to replace: var xml = await rootBundle.loadString("assets/test_form1.xml"); with something like

var response = await http.get(requestUrl);
var xml = response.body;

I don't think it is a good idea to setup a real server somewhere, because the example would not work when the server is offline and I would also need to keep the server up to date with the example data.

I can extend the example to show how I collect the values from the form and print them to console, Would that be sufficient?

joeblew99 commented 5 years ago

Hi, thanks for opening the issue.

Can you please explain why do you need the real server? To get the xml you just need to replace: var xml = await rootBundle.loadString("assets/test_form1.xml"); with something like

var response = await http.get(requestUrl);
var xml = response.body;

Ok that helps. Know i know how to do it.

I don't think it is a good idea to setup a real server somewhere, because the example would not work when the server is offline and I would also need to keep the server up to date with the example data.

i dont mean to run a real server. Just put example code of a server. In dart , golang , whatever. Its nice to see both sides of the flow, thats all.

I can extend the example to show how I collect the values from the form and print them to console, Would that be sufficient?

Yes i think thats a good for idea.

OndrejKunc commented 5 years ago

i dont mean to run a real server. Just put example code of a server. In dart , golang , whatever. Its nice to see both sides of the flow, thats all.

I still think it is not a good idea to write a server. If I would choose anything other than dart, it would be useless for most of the people. I think better idea is to create some object called MockServer that would have one get method and one post method and the implementation can also load data from assets, but it would be easier to see the flow. I will update the example when I have some time.

I can extend the example to show how I collect the values from the form and print them to console, Would that be sufficient?

Yes i think thats a good for idea.

Actually I just realized: if you run the example app and choose the 'Dynamic Form with Bloc' and you press the Ok button, then you should see a dialog with list of values in a format: <elementId> <propertyName> <value>

This list contains all the properties that are parsed as a mutable property. The idea behind this logic is that you should send back to the server only the properties that can be changed on the client not the whole form. I will also update documentation with this info.