Skip to content

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

Closed

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.

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    c: proposalA detailed proposal for a change to Flutter
    team-toolOwned by Flutter Tool team
    on Mar 13, 2026
  2. mbcorona commented on Mar 13, 2026

    @mbcorona
    Member

    Routing to the tool team to evaluate the proposed flag for the flutter clean command. Noted the linked PR.

  3. github-actions commented on Apr 28, 2026

    @github-actions

    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 -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions