What is tree shaking in Flutter?

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.