Skip to content

flutter clean should support cleaning the standard example/ app in package projects #183450

Description

@andeart

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: proposalA detailed proposal for a change to Flutterteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions