Patchwork: A Dart/Flutter Tool That Patches Third-Party Packages Without Forking
For Flutter teams that frequently patch third-party packages for urgent fixes or internal features, Patchwork eliminates the overhead of maintaining forks and the risk of committing dirty local changes. It brings a mature Node.js workflow to Dart, making dependency patching reproducible, shareable, and CI-friendly.
Patchwork is a new open-source tool for Dart and Flutter projects that brings the `patch-package` workflow from the Node.js ecosystem to pub dependencies. Instead of forking an entire repository to fix a bug or add a temporary feature, developers can edit the package source locally, commit the changes as a standard unified diff `.patch` file, and apply it across the team.
The workflow has three stages. First, `patchwork patch <package>` copies the package source into two directories under `.dart_tool/patchwork/`: a read-only baseline snapshot and an editable copy. After making changes, `patchwork patch --commit <package>` generates a diff using `git diff --no-index` and validates it with `git apply --check`. Finally, `patchwork apply` reads the lock file, applies the patch to a fresh copy of the original source, and writes a `pubspec_overrides.yaml` entry pointing to the patched directory.
Only `patchwork.lock` and the `.patch` files are committed to version control. The `.dart_tool/patchwork/` directory is fully reproducible and can be rebuilt on any machine. The tool also supports automatic rollback on failure via file snapshots taken during the commit phase.
Patchwork solves a real pain point: Flutter developers often resort to directly editing local package caches, which breaks on the next pub get and cannot be shared.
By using pubspec_overrides.yaml instead of modifying pubspec.yaml, Patchwork keeps the project's dependency declarations clean and avoids merge conflicts.
The reliance on git diff and git apply means the tool is lightweight and leverages battle-tested infrastructure rather than implementing its own diff engine.
The three-stage workflow (session, commit, apply) mirrors a developer's natural debugging flow: explore, save, and deploy.
Patchwork is a sign that the Dart/Flutter ecosystem is maturing — it is adopting workflows that have proven essential in larger JavaScript ecosystems.