maskFilter static method

MaskFilter? maskFilter(
  1. DataSource source,
  2. List<Object> key
)

Returns a MaskFilter from the specified map.

The type key specifies the kind of mask filter.

A type of blur creates a MaskFilter.blur. The style key (enumValue of BlurStyle, defaults to BlurStyle.normal) is used as the blur style, and the sigma key (double, defaults to 1.0) is used as the blur sigma.

If the type is none of these, but is not null, then the type is looked up in maskFilterDecoders, and if an entry is found, this method defers to that callback.

Otherwise, returns null.

Implementation

static MaskFilter? maskFilter(DataSource source, List<Object> key) {
  final String? type = source.v<String>([...key, 'type']);
  switch (type) {
    case null:
      return null;
    case 'blur':
      return MaskFilter.blur(
        enumValue<BlurStyle>(BlurStyle.values, source, [...key, 'style']) ?? BlurStyle.normal,
        source.v<double>([...key, 'sigma']) ?? 1.0,
      );
    default:
      final ArgumentDecoder<MaskFilter?>? decoder = maskFilterDecoders[type];
      if (decoder == null) {
        return null;
      }
      return decoder(source, key);
  }
}