from static method

Control? from({
  1. required Map<String, dynamic> schema,
  2. required String scope,
  3. required ValueChanged onValueChanged,
  4. Map<String, dynamic>? options,
  5. bool isRequired = false,
  6. dynamic defaultValue,
  7. Key? key,
})

Implementation

static Control? from({
  required Map<String, dynamic> schema,
  required String scope,
  required jfc.ValueChanged onValueChanged,
  Map<String, dynamic>? options,
  bool isRequired = false,
  dynamic defaultValue,
  Key? key,
}) {
  switch (schema["type"]) {
    case ControlTypes.string:
      return JFCString(
        schema: schema,
        scope: scope,
        onValueChanged: onValueChanged,
        isRequired: isRequired,
        defaultValue: defaultValue,
        enumeration:
            schema["enum"] != null ? List<String>.from(schema["enum"]) : null,
        options: options,
        key: key,
      );

    case ControlTypes.integer:
      return JFCNumber(
        schema: schema,
        scope: scope,
        onValueChanged: onValueChanged,
        isRequired: isRequired,
        defaultValue: defaultValue,
        options: options,
        key: key,
      );

    case ControlTypes.number:
      return JFCNumber(
        schema: schema,
        scope: scope,
        onValueChanged: onValueChanged,
        isRequired: isRequired,
        defaultValue: defaultValue,
        options: options,
        precision: 2,
        key: key,
      );

    case ControlTypes.boolean:
      return JFCBoolean(
        schema: schema,
        scope: scope,
        onValueChanged: onValueChanged,
        isRequired: isRequired,
        defaultValue: defaultValue,
        options: options,
        key: key,
      );

    default:
      return null;
  }
}