drawImageNine method Null safety

void drawImageNine(
  1. Image image,
  2. Rect center,
  3. Rect dst,
  4. Paint paint
)

Draws the given Image into the canvas using the given Paint.

The image is drawn in nine portions described by splitting the image by drawing two horizontal lines and two vertical lines, where the center argument describes the rectangle formed by the four points where these four lines intersect each other. (This forms a 3-by-3 grid of regions, the center region being described by the center argument.)

The four regions in the corners are drawn, without scaling, in the four corners of the destination rectangle described by dst. The remaining five regions are drawn by stretching them to fit such that they exactly cover the destination rectangle while maintaining their relative positions.

Implementation

void drawImageNine(Image image, Rect center, Rect dst, Paint paint) {
  assert(image != null); // image is checked on the engine side
  assert(_rectIsValid(center));
  assert(_rectIsValid(dst));
  assert(paint != null);
  final String? error = _drawImageNine(image._image,
                                       center.left,
                                       center.top,
                                       center.right,
                                       center.bottom,
                                       dst.left,
                                       dst.top,
                                       dst.right,
                                       dst.bottom,
                                       paint._objects,
                                       paint._data,
                                       paint.filterQuality.index);
  if (error != null) {
    throw PictureRasterizationException._(error, stack: image._debugStack);
  }
}