What is tree shaking in Flutter?
Why Interviewers Ask This
Advanced questions like this reveal whether a candidate has internalized Flutter deeply enough to make architectural decisions. Strong answers demonstrate both breadth and depth of experience.
Answer
Tree shaking is a build-time optimization performed by the Dart compiler in release mode. It statically analyzes the code and removes all unused functions, classes, and even individual Material/Cupertino icons that are never referenced in your code. This significantly reduces the final app size. For Material icons, Flutter only includes the specific icon glyphs you use — importing the full icons font without tree shaking would add several MB. Always test your release build size, as debug builds include the full code and are not tree-shaken.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.