fillBackground method Null safety

void fillBackground(
  1. int color
)

Set all of the empty pixels (for png's) of the image to the given color.

Implementation

void fillBackground(int color) {
  // loop all pixels
  for (var i = 0; i < length; i++) {
    // value 0 means null pixel
    if (data[i] == 0) {
      // set the pixel to the given color
      data[i] = color;
    }
  }
}