Repository navigation
flutter clean should support cleaning the standard example/ app in package projects #183450
Description
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:
- [native_assets]
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)- [flutter cli] flutter clean should support a --directory option like flutter pub get does #131395 (more extensive request, understandably closed)
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-exampleBehavior:
- When run in a Flutter package project containing an
example/directory,flutter clean --include-examplewould also run the clean process inexample/. flutter cleanwithout the flag retains its current behavior for backwards compatibility.- If
--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 clean command.
Activity
mbcorona commentedon Mar 13, 2026
Routing to the tool team to evaluate the proposed flag for the flutter clean command. Noted the linked PR.
Add `--include-example` flag to `flutter clean` for package example p…
Add `--include-example` flag to `flutter clean` for package example p…
github-actions commentedon Apr 28, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.