imageFilter property Null safety

ImageFilter? imageFilter

The ImageFilter to use when drawing raster images.

For example, to blur an image using Canvas.drawImage, apply an ImageFilter.blur:

import 'dart:ui' as ui;

ui.Image image;

void paint(Canvas canvas, Size size) {
  canvas.drawImage(
    image,
    Offset.zero,
    Paint()..imageFilter = ui.ImageFilter.blur(sigmaX: .5, sigmaY: .5),
  );
}

See also:

Implementation

ImageFilter? get imageFilter {
  return _objects?[_kImageFilterIndex]?.creator as ImageFilter?;
}
void imageFilter=(ImageFilter? value)

Implementation

set imageFilter(ImageFilter? value) {
  if (value == null) {
    if (_objects != null) {
      _objects![_kImageFilterIndex] = null;
    }
  } else {
    final List<dynamic> objects = _ensureObjectsInitialized();
    if (objects[_kImageFilterIndex]?.creator != value) {
      objects[_kImageFilterIndex] = value._toNativeImageFilter();
    }
  }
}