Flutter & Dart (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is `saveLayer()` and why is it expensive for GPU performance?
senior LevelFormsPerformance
In Simple Words:
saveLayer() redirects rendering to an off-screen intermediate texture buffer before composite-rendering it back to the screen:
- Triggered by
Opacity(when applied to complex subtrees),ShaderMask, andClipRRect. - Forces GPU pipeline flushes and consumes high memory bandwidth.
- Optimization: Avoid wrapping complex lists in
Opacity; use color opacity (Color.withOpacity()) directly instead.