fromJsonOrNull static method
Constructs a new instance of FieldModel,
from json, which must be a valid JSON object. Returns null if
json is null or if the conversion fails.
Implementation
static FieldModel? fromJsonOrNull(
Map<String, dynamic>? json,
) {
try {
final fieldPath = json?['fieldPath'];
final fieldType = json?['fieldType'];
final nullable = letBoolOrNull(json?['nullable']);
final children = letListOrNull<dynamic>(json?['children'])
?.map(
(p0) => letMapOrNull<dynamic, dynamic>(p0)
?.map(
(p0, p1) => MapEntry(
p0?.toString().trim().nullIfEmpty,
p1,
),
)
.nonNulls
.nullIfEmpty
?.unmodifiable,
)
.nonNulls
.nullIfEmpty
?.toList()
.unmodifiable;
final primaryKey = letBoolOrNull(json?['primaryKey']);
final foreignKey = letBoolOrNull(json?['foreignKey']);
final description = json?['description']?.toString().trim().nullIfEmpty;
final references = json?['references'];
final columnDefault =
json?['columnDefault']?.toString().trim().nullIfEmpty;
return FieldModel(
fieldPath: fieldPath,
fieldType: fieldType,
nullable: nullable,
children: children,
primaryKey: primaryKey,
foreignKey: foreignKey,
description: description,
references: references,
columnDefault: columnDefault,
);
} catch (e) {
return null;
}
}