fromJsonOrNull static method
Constructs a new instance of GenerateDartModel,
from json
, which must be a valid JSON object. Returns null
if
json
is null
or if the conversion fails.
Implementation
static GenerateDartModel? fromJsonOrNull(
Map<String, dynamic>? json,
) {
try {
final className = json?['className']?.toString().trim().nullIfEmpty;
final fields = letSetOrNull<dynamic>(json?['fields'])
?.map(
(p0) => p0,
)
.nonNulls
.nullIfEmpty
?.toSet();
final shouldInherit = letAsOrNull<bool>(json?['shouldInherit']);
final inheritanceConstructor =
json?['inheritanceConstructor']?.toString().trim().nullIfEmpty;
final keyStringCase =
json?['keyStringCase']?.toString().trim().nullIfEmpty;
final description = json?['description']?.toString().trim().nullIfEmpty;
return GenerateDartModel(
className: className,
fields: fields,
shouldInherit: shouldInherit,
inheritanceConstructor: inheritanceConstructor,
keyStringCase: keyStringCase,
description: description,
);
} catch (e) {
return null;
}
}