Chrome.fromJson constructor
Retrieve Chrome instance form data
. If data
is
not valid, Chrome.internal is returned.
const chrome = Chrome.fromJson(data)
Implementation
factory Chrome.fromJson(Map<String, dynamic> data) {
//```codec
const c = ColorCodec();
//```
return Chrome(
swatch: Colors.primaries.elementAtOrNull(data['swatch']),
foreground: c.decode(data['foreground']) ?? internal.foreground,
background: c.decode(data['background']) ?? internal.background,
//...surface
primary: c.decode(data['primary']) ?? internal.primary,
secondary: c.decode(data['secondary']) ?? internal.secondary,
ascent: c.decode(data['ascent']) ?? internal.ascent,
//...on surface
onPrimary: c.decode(data['onPrimary']),
onSecondary: c.decode(data['onSecondary']),
onAscent: c.decode(data['onAscent']),
//...extras
success: c.decode(data['success']) ?? internal.success,
error: c.decode(data['error']) ?? internal.error,
warning: c.decode(data['warning']) ?? internal.warning,
tint: c.decode(data['tint']) ?? internal.tint,
shade: c.decode(data['shade']) ?? internal.shade,
);
}