draw method

Future draw({
  1. Rect? area,
  2. bool redraw = true,
})

Push a region of the buffer to the underlying texture and optionally redraw it

If area is specified, only the pixels that fall within it are pushed from buffer to the texture data, otherwise, the entire buffer is used. If redraw is true or unspecified, the texture will be refreshed with its new contents.

Implementation

Future<dynamic> draw({Rect? area, bool redraw = true}) async {
  int x = area?.left.toInt() ?? 0;
  int y = area?.top.toInt() ?? 0;
  int w = area?.width.toInt() ?? width;
  int h = area?.height.toInt() ?? height;
  Future<void> draw = _plugin.draw(textureId, x, y, w, h, buffer);
  if (redraw) {
    Future<void> invalidate = _plugin.invalidate(textureId);
    return Future.wait([draw, invalidate]);
  }
  return draw;
}