fromJson static method
Implementation
static InlineBannerImageConfig? fromJson(Map<String, dynamic>? json) {
if (json == null) return null;
final url = optString(json, 'url').trim();
if (url.isEmpty) return null;
final aspectRatio = optDouble(json, 'aspectRatio', 16 / 9);
final height = optDouble(json, 'height', 200);
final cornerRadius = optDouble(json, 'cornerRadius', 12);
return InlineBannerImageConfig(
url: url,
placeholder: ImagePlaceholder.fromJson(optMap(json, 'placeholder')),
boxFit: switch (optString(json, 'boxFit', 'cover')) {
'contain' => BoxFit.contain,
'fill' => BoxFit.fill,
_ => BoxFit.cover,
},
aspectRatio: _nonNegative(aspectRatio, 16 / 9),
height: _nonNegative(height, 200),
cornerRadius: _nonNegative(cornerRadius, 12),
);
}