generateEditingControllerMapping function

Map<String, dynamic> generateEditingControllerMapping(
  1. JsonSchema jsonSchema
)

Takes as an argument a JsonSchema and return a Map<String, dynamic> where the keys are the names of the properties and the values are instances of TextEditingController for the corresponding properties on the FlutterJSONSchemaForm or similar maps on recursive fashion

Implementation

Map<String, dynamic> generateEditingControllerMapping(JsonSchema jsonSchema) {
  // for each property on the JSON Schema
  return jsonSchema.properties.map((key, value) {
    // if the property is an object
    if (value.type == JsonSchemaType.object) {
      // if the property is an object, then we need to create a map with the
      // same name and the same type of the object
      return MapEntry(key, generateEditingControllerMapping(value));
    } else {
      // if the property is a value, then we need to create a controller
      return MapEntry(key, TextEditingController());
    }
  });
}