ComponentModel.fromJson constructor
ComponentModel.fromJson(
- Map<String, dynamic> json
)
Implementation
factory ComponentModel.fromJson(Map<String, dynamic> json) {
final validate = json['validate'] as Map<String, dynamic>?;
// Create a copy of the JSON to avoid mutating the original
final rawCopy = Map<String, dynamic>.from(json);
return ComponentModel(
type: json['type']?.toString() ?? 'unknown',
key: json['key']?.toString() ?? '',
label: json['label']?.toString() ?? '',
hideLabel: json['hideLabel'] == true,
placeholder: json['placeholder']?.toString(),
required: validate?['required'] == true || validate?['required'] == 'true',
disabled: json['disabled'] == true,
description: json['description']?.toString(),
prefix: json['prefix']?.toString(),
suffix: json['suffix']?.toString(),
defaultValue: json['defaultValue'],
raw: rawCopy,
);
}