maskFilter property Null safety

MaskFilter? maskFilter

A mask filter (for example, a blur) to apply to a shape after it has been drawn but before it has been composited into the image.

See MaskFilter for details.

Implementation

MaskFilter? get maskFilter {
  switch (_data.getInt32(_kMaskFilterOffset, _kFakeHostEndian)) {
    case MaskFilter._TypeNone:
      return null;
    case MaskFilter._TypeBlur:
      return MaskFilter.blur(
        BlurStyle.values[_data.getInt32(_kMaskFilterBlurStyleOffset, _kFakeHostEndian)],
        _data.getFloat32(_kMaskFilterSigmaOffset, _kFakeHostEndian),
      );
  }
  return null;
}
void maskFilter=(MaskFilter? value)

Implementation

set maskFilter(MaskFilter? value) {
  if (value == null) {
    _data.setInt32(_kMaskFilterOffset, MaskFilter._TypeNone, _kFakeHostEndian);
    _data.setInt32(_kMaskFilterBlurStyleOffset, 0, _kFakeHostEndian);
    _data.setFloat32(_kMaskFilterSigmaOffset, 0.0, _kFakeHostEndian);
  } else {
    // For now we only support one kind of MaskFilter, so we don't need to
    // check what the type is if it's not null.
    _data.setInt32(_kMaskFilterOffset, MaskFilter._TypeBlur, _kFakeHostEndian);
    _data.setInt32(_kMaskFilterBlurStyleOffset, value._style.index, _kFakeHostEndian);
    _data.setFloat32(_kMaskFilterSigmaOffset, value._sigma, _kFakeHostEndian);
  }
}