BackgroundSpec.fromJson constructor
BackgroundSpec.fromJson(
- Object? json
Implementation
factory BackgroundSpec.fromJson(Object? json) {
final j = _map(json, 'BackgroundSpec');
final colors = j['colors'];
if (colors is! List) throw const FormatException('Expected colors list');
return BackgroundSpec(
kind: _enumByName(BackgroundKind.values, j['kind'], 'background'),
colors: List.unmodifiable(colors.map(argbFromHex)),
angleTenths: _int(j, 'angleTenths'),
pattern: _enumByName(BackgroundPattern.values, j['pattern'], 'pattern'),
patternColor: argbFromHex(j['patternColor']),
patternScaleCdp: _int(j, 'patternScaleCdp'),
patternOpacityPermille: _int(j, 'patternOpacityPermille'),
driftPeriodMs: _int(j, 'driftPeriodMs'),
);
}