Boy Scout Rule Flutter: 10 Five-Minute Cleanups
The boy scout rule Flutter devs can actually use: leave every file a little cleaner than you found it. Ten five-minute cleanups with before/after Dart code, plus guardrails against scope creep.
Most codebases don't rot from one catastrophic decision β they rot because nobody tidies up. The boy scout rule Flutter teams actually follow is simple: leave every file a little cleaner than you found it. Five minutes here, a rename there, a dead import removed β and after a year your codebase gets *better* instead of worse, with zero dedicated refactoring sprints. Here are ten five-minute cleanups with real before/after Dart examples, plus the guardrails that keep this habit from becoming scope creep. What you'll learn What "opportunistic refactoring" means in a Flutter codebase (Fowler's three types) 10 concrete five-minute cleanups with before/after Dart code How to spot litter-pickup opportunities while passing through a file The separate-commit rule that keeps reviewers on your side When to clean now, later, or never (decision table) 5 scope-creep mistakes that make reviewers hate boy scouts π¬ Watch: boy scout rule Watch a real-talk breakdown of Uncle Bob's Clean Code, including the Boy Scout Rule chapter, before you apply it to your Flutter codebase. TBD β± TBD Β· Unknown β click to play inline, or watch on YouTube . What "opportunistic refactoring" means in a Flutter codebase Martin Fowler's term for the boy scout rule is *opportunistic refactoring*: you refactor not on a schedule, but at the moment you already have the file open for another reason. Fowler splits it into three flavors, and all three show up constantly in Flutter work: Litter-pickup refactoring β you spot something small and ugly while passing through (a vague variable name, a dead import) and fix it on the spot. The purest boy scout move. Comprehension refactoring β you rename or restructure code *in order to understand it*. Restructuring that build() of nested ternariesβ¦