fieldToInput static method

Widget fieldToInput({
  1. required Field field,
  2. required bool creationMode,
  3. int? deepLevel,
  4. ValueChanged<List<DynamicFieldItem>>? onChangeChildStructure,
  5. ValueChanged<List<StructuredFieldItem>>? onChildChange,
  6. List<DynamicFieldItem>? initialChildrenData,
})

Implementation

static Widget fieldToInput({
  required Field field,
  required bool creationMode,
  int? deepLevel,

  /// ? Dynamic Field recursive callback
  ValueChanged<List<DynamicFieldItem>>? onChangeChildStructure,

  /// ? Structured field recursive callback
  ValueChanged<List<StructuredFieldItem>>? onChildChange,

  /// ? Dynamic field recursive initial data
  List<DynamicFieldItem>? initialChildrenData,
}) {
  if (field is BinaryField) {
    // TODO(alphamikle): If the binary field will be used - it's need to be implemented
    return const SizedBox.shrink();
  } else if (field is BoolField) {
    return BoolFieldCell(field: field, creationMode: creationMode);
  } else if (field is ColorField) {
    return ColorFieldCell(field: field, creationMode: creationMode);
  } else if (field is DateTimeField) {
    return DateFieldCell(field: field, creationMode: creationMode);
  } else if (field is EnumField) {
    return EnumFieldCell(field: field, creationMode: creationMode);
  } else if (field is FontField) {
    return FontFieldCell(field: field, creationMode: creationMode);
  } else if (field is HeaderField) {
    return HeaderFieldCell(field: field);
  } else if (field is IconField) {
    return IconFieldCell(field: field, creationMode: creationMode);
  } else if (field is IdField) {
    return IdFieldCell(field: field, creationMode: creationMode);
  } else if (field is ModelsSelectorField) {
    return ModelsSelectorFieldCell(field: field, creationMode: creationMode);
  } else if (field is StringField) {
    return StringFieldCell(field: field, creationMode: creationMode);
  } else if (field is MultiSelectorField) {
    return MultiSelectorFieldCell(field: field, creationMode: creationMode);
  } else if (field is NumberField) {
    return NumberFieldCell(field: field, creationMode: creationMode);
  } else if (field is QueryFilterField) {
    return QueryFilterCell(
      field: field,
      creationMode: creationMode,
      onChildChange: onChildChange,
      deepLevel: deepLevel ?? 0,
    );
  } else if (field is QueryFilterValueField) {
    return QueryFilterValueFieldCell(field: field, creationMode: creationMode);
  } else if (field is ScreenField) {
    return ScreenFieldCell(field: field, creationMode: creationMode);
  } else if (field is SelectorField) {
    return SelectorFieldCell(field: field, creationMode: creationMode);
  } else if (field is StructureField) {
    return StructureFieldCell(field: field, creationMode: creationMode);
  } else if (field is StructuredField) {
    return StructuredFieldCell(
      field: field,
      creationMode: creationMode,
      onChildChange: onChildChange,
      deepLevel: deepLevel ?? 0,
    );
  } else if (field is DynamicField) {
    return DynamicFieldCell(
      field: field,
      creationMode: creationMode,
      deepLevel: deepLevel ?? 0,
      onChangeChildStructure: onChangeChildStructure,
      initialChildrenData: initialChildrenData ?? [],
    );
  }
  // TODO(alphamikle): [FIELDS] Add new fields here
  final String warning = '$field mapper is not implemented!';
  logInfo('$warning\n${StackTrace.current}');
  return ErrorFieldCell(warning: warning);
}