fromWire static method
Total, like every fromWire here: an unreadable payload is null rather
than a throw, and null means "the text's own colour".
Implementation
static ScenePaint? fromWire(Object? raw) => switch (raw) {
// A bare number is a solid colour — the cheapest spelling, and what a
// colour already travels as everywhere else.
num argb => SolidPaint(SceneColor(argb.toInt())),
Map m when m['k'] == 'linear' => LinearPaint(
colors: _wireColors(m),
stops: _wireStops(m),
begin: SceneAlignment.fromWire(m['begin'], SceneAlignment.topCenter),
end: SceneAlignment.fromWire(m['end'], SceneAlignment.bottomCenter),
),
Map m when m['k'] == 'radial' => RadialPaint(
colors: _wireColors(m),
stops: _wireStops(m),
center: SceneAlignment.fromWire(m['center'], SceneAlignment.center),
radius: _wireDouble(m['r'], 1),
),
Map m when m['k'] == 'sweep' => SweepPaint(
colors: _wireColors(m),
stops: _wireStops(m),
center: SceneAlignment.fromWire(m['center'], SceneAlignment.center),
startAngle: _wireDouble(m['a0'], 0),
endAngle: _wireDouble(m['a1'], 360),
),
Map m when m['k'] == 'shader' => switch (m['asset']) {
String asset => ShaderPaint(asset, uniforms: _wireUniforms(m['u'])),
_ => null,
},
_ => null,
};