What is RepaintBoundary and when should you use it?

Answer

RepaintBoundary promotes its child widget to its own compositing layer. When only the child changes, Flutter can repaint just that layer and composite it with the other unchanged layers, without repainting the rest of the screen. Use it around widgets that repaint frequently but are visually isolated — like a custom animated widget, a video player, or a rapidly updating progress indicator. The tradeoff is extra memory for the additional layer. You can verify if your RepaintBoundary is helping by enabling the "Show repaint rainbow" in DevTools.