我想在颤动中创建表单 . 但是,将在表单中使用的小部件未预定义 . 使用哪些小部件将由json响应确定 . 有没有办法在运行时创建小部件并管理它们的状态 .
json看起来像下面的样子
{
id:1,
Answer: "Click on Register button so that we can get you started",
Widget:[
"google OAuth"
],
ReplyUrl:"www.example.com/api"
}
{
id:2,
Widget: [
{
"Question":"What is your name ?",
"Type":"text",
"VariableName":"Onboarding_Name"
},
{
"Question":"What is your birth date ?",
"Type":"date",
"VariableName":"Onboarding_BirthDate"
}
],
ReplyUrl:"www.example.com/api"
}
1 回答
假设您的模型类是
Question
,并且您想为列表中的每个Question
创建一个小部件:你只需映射它们: