imageFilter property Null safety
The ImageFilter to use when drawing raster images.
For example, to blur an image using Canvas.drawImage, apply an ImageFilter.blur:
void paint(Canvas canvas, Size size) {
canvas.drawImage(
_image,
ui.Offset.zero,
Paint()..imageFilter = ui.ImageFilter.blur(sigmaX: 0.5, sigmaY: 0.5),
);
}
See also:
- MaskFilter, which is used for drawing geometry.
Implementation
ImageFilter? get imageFilter {
final _ImageFilter? nativeFilter = _objects?[_kImageFilterIndex] as _ImageFilter?;
return nativeFilter?.creator;
}
Implementation
set imageFilter(ImageFilter? value) {
if (value == null) {
if (_objects != null) {
_objects![_kImageFilterIndex] = null;
}
} else {
final List<Object?> objects = _ensureObjectsInitialized();
final _ImageFilter? imageFilter = objects[_kImageFilterIndex] as _ImageFilter?;
if (imageFilter?.creator != value) {
objects[_kImageFilterIndex] = value._toNativeImageFilter();
}
}
}