Open vijaymsc opened 4 months ago
I'm not entirely sure I'm understanding the question. Also, would you mind edititing your comment to use the triple backtick so that it formats correctly? It's hard to read as-is.
I need dynamically register registerFunctions based json, example if i add new button in my widget json file my onpressed function also add dynamically in registerFunctions .
You can define set of validators - https://github.com/peiffer-innovations/form_validation, use them like that: https://github.com/peiffer-innovations/json_dynamic_widget/blob/main/json_dynamic_widget/example/assets/pages/form.json#L208-L215 and mostly depends on bool valid = Form.of(context).validate();
You can pass all variables in a list and create a dynamic logic which creates the body from them and send to your server
Thanks for your response, but I need to add a new button in my json at the time my newly added button onTap function is not registered in my live app or apk, so give an error because of function not registered . That's why I'm asking that registerFunctions also dynamically register. I don't know if this is possible; if possible, please guide me. @crisperit @jpeiffer
You can call registerFunctions
whenever you want async
I guess the main problem is that your functions and views that they need to handle are too coupled.
I think that you should have a single, generic function that just receives all variables via the args like validateForm('form_context',['user_email','user_password'])
and convert it to some json body and send to the server for the validation.
It is worth also to consider https://github.com/peiffer-innovations/json_dynamic_widget_plugin_js which sort of is giving possibility to "generate" functions on the view side. You can inject some JS code as a function via the view