Use case
When developing a Dart/Flutter package (plugin or otherwise), the project typically contains an example/ directory with a standalone Dart/Flutter app used for testing (also referenced here). Currently, running flutter clean at the package root only cleans the package-level build artifacts. It does not clean the example/ app's build artifacts (example/build/, example/.dart_tool/, etc.).
To fully clean/reset a package project, we currently need to:
flutter clean
cd example
flutter clean
cd ..
This can be easy to miss, and stale build artifacts in example/ can cause confusing build failures (after dependency changes, Flutter upgrades, etc). Many developers (myself too) run and debug the example app directly from the package root rather than cd-ing into example/, making it natural to also run flutter clean from the root and assume the example app is covered.
I searched for existing issues and found some adjacent ones but none addressing this specific goal:
As I understand from having browsed through these and similar threads re: flutter clean scope, the expectation when running flutter clean in a project (package or otherwise) is that the project ends up in a fully clean state. Let me know if I'm missing something please.
I also searched pub.dev and didn't find a package that addresses this.
Proposal
Add an --include-example optional flag (or similar phrasing) to flutter clean:
flutter clean --include-example
Behavior:
- When run in a Flutter package project containing an
example/ directory, flutter clean --include-example would also run the clean process in example/.
flutter clean without the flag retains its current behavior for backwards compatibility.
- If
--include-example is passed but no example/ directory exists, it completes normally (no error).
I think this is best provided by Flutter tools directly rather than a pub dev tool, since it is a behavioral addition to the clean command.
Use case
When developing a Dart/Flutter package (plugin or otherwise), the project typically contains an
example/directory with a standalone Dart/Flutter app used for testing (also referenced here). Currently, runningflutter cleanat the package root only cleans the package-level build artifacts. It does not clean theexample/app's build artifacts (example/build/,example/.dart_tool/, etc.).To fully clean/reset a package project, we currently need to:
This can be easy to miss, and stale build artifacts in
example/can cause confusing build failures (after dependency changes, Flutter upgrades, etc). Many developers (myself too) run and debug the example app directly from the package root rather thancd-ing intoexample/, making it natural to also runflutter cleanfrom the root and assume the example app is covered.I searched for existing issues and found some adjacent ones but none addressing this specific goal:
flutter cleanshould delete all native assets #151890 (focuses on native assets, but a comment mentions the need forflutter cleandoing whatever is necessary to reset the project)flutter cleandoesn't clean everything #12631 (focuses on iOS artifacts)As I understand from having browsed through these and similar threads re:
flutter cleanscope, the expectation when runningflutter cleanin a project (package or otherwise) is that the project ends up in a fully clean state. Let me know if I'm missing something please.I also searched pub.dev and didn't find a package that addresses this.
Proposal
Add an
--include-exampleoptional flag (or similar phrasing) toflutter clean:Behavior:
example/directory,flutter clean --include-examplewould also run the clean process inexample/.flutter cleanwithout the flag retains its current behavior for backwards compatibility.--include-exampleis passed but noexample/directory exists, it completes normally (no error).I think this is best provided by Flutter tools directly rather than a pub dev tool, since it is a behavioral addition to the
cleancommand.