fieldTypeToField<T extends Field> static method

T fieldTypeToField<T extends Field>(
  1. FieldType fieldType
)

Implementation

static T fieldTypeToField<T extends Field>(FieldType fieldType) {
  if (fieldType == FieldType.binaryField) {
    return BinaryField.empty() as T;
  } else if (fieldType == FieldType.boolField) {
    return BoolField.empty() as T;
  } else if (fieldType == FieldType.colorField) {
    return ColorField.empty() as T;
  } else if (fieldType == FieldType.dateField) {
    return DateTimeField.empty() as T;
  } else if (fieldType == FieldType.enumField) {
    return EnumField.empty() as T;
  } else if (fieldType == FieldType.fontField) {
    return FontField.empty() as T;
  } else if (fieldType == FieldType.headerField) {
    return HeaderField.empty() as T;
  } else if (fieldType == FieldType.iconField) {
    return IconField.empty() as T;
  } else if (fieldType == FieldType.idField) {
    return IdField.empty() as T;
  } else if (fieldType == FieldType.modelsSelectorField) {
    return ModelsSelectorField.empty() as T;
  } else if (fieldType == FieldType.stringField) {
    return StringField.empty() as T;
  } else if (fieldType == FieldType.multiSelectorField) {
    return MultiSelectorField.empty() as T;
  } else if (fieldType == FieldType.numberField) {
    return NumberField.empty() as T;
  } else if (fieldType == FieldType.queryFilterField) {
    return QueryFilterField.empty() as T;
  } else if (fieldType == FieldType.queryFilterValueField) {
    return QueryFilterValueField.empty() as T;
  } else if (fieldType == FieldType.screenField) {
    return ScreenField.empty() as T;
  } else if (fieldType == FieldType.selectorField) {
    return SelectorField.empty() as T;
  } else if (fieldType == FieldType.structureField) {
    return StructureField.empty() as T;
  } else if (fieldType == FieldType.structuredField) {
    return StructuredField.empty() as T;
  } else if (fieldType == FieldType.dynamicField) {
    return DynamicField.empty() as T;
  }
  // TODO(alphamikle): [FIELDS] Add new fields here
  throw Exception('Unknown field type: $fieldType');
}