shader static method
Returns a Shader based on the specified map.
The type
key specifies the kind of shader.
A type of linear
, radial
, or sweep
is interpreted as described by
gradient; then, the gradient is compiled to a shader by applying the
rect
(interpreted by rect) and textDirection
(interpreted as an
enumValue of TextDirection) using the Gradient.createShader method.
If the type is none of these, but is not null, then the type is looked up in shaderDecoders, and if an entry is found, this method defers to that callback.
Otherwise, returns null.
Implementation
static Shader? shader(DataSource source, List<Object> key) {
final String? type = source.v<String>([...key, 'type']);
switch (type) {
case null:
return null;
case 'linear':
case 'radial':
case 'sweep':
return gradient(source, key)!.createShader(
rect(source, [...key, 'rect']) ?? Rect.zero,
textDirection: enumValue<TextDirection>(TextDirection.values, source, ['textDirection']) ?? TextDirection.ltr,
);
default:
final ArgumentDecoder<Shader?>? decoder = shaderDecoders[type];
if (decoder == null) {
return null;
}
return decoder(source, key);
}
}