NiceFormFieldDef.fromJson constructor

NiceFormFieldDef.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory NiceFormFieldDef.fromJson(Map<String, dynamic> json) {
  return NiceFormFieldDef(
    key: json['key'] as String,
    type: NiceFormFieldType.values.firstWhere(
      (t) => t.name == json['type'],
      orElse: () => NiceFormFieldType.text,
    ),
    label: json['label'] as String?,
    hint: json['hint'] as String?,
    required: json['required'] as bool? ?? false,
    readOnly: json['readOnly'] as bool? ?? false,
    defaultValue: json['defaultValue'],
    options: (json['options'] as List?)?.cast<String>(),
    flex: json['flex'] as int? ?? 1,
  );
}