ft_patch_package 1.0.1 copy "ft_patch_package: ^1.0.1" to clipboard
ft_patch_package: ^1.0.1 copied to clipboard

Patch Flutter & Dart packages like React Native's patch-package. Create, store, and auto-apply patches to pub dependencies after pub get. Fix bugs in third-party packages without forking.

ft_patch_package #

Patch Flutter & Dart packages like React Native's patch-package.

Make fixes to packages in .pub-cache, generate portable patch files, store them in version control, and apply them automatically after flutter pub get.

Why? #

When a Flutter package has a bug but the maintainer hasn't published a fix yet, you need a way to:

  1. Apply your fix locally
  2. Share the fix with your team
  3. Survive flutter pub get / flutter clean

ft_patch_package solves this by creating portable patch files that work on any machine.

Installation #

dev_dependencies:
  ft_patch_package: ^1.0.0

Usage #

Step 1: Create a snapshot #

dart run ft_patch_package start <package_name>

This saves the original state of the package before you edit it.

Step 2: Make your changes #

Edit the package files directly in .pub-cache:

~/.pub-cache/hosted/pub.flutter-io.cn/<package_name>-<version>/

Step 3: Generate the patch #

dart run ft_patch_package done <package_name>

This creates a portable patch file at patches/<package_name>+<version>.patch.

Step 4: Commit & apply #

# Commit the patches directory
git add patches/
git commit -m "Patch <package_name>: fix description"

# After flutter pub get, apply patches
dart run ft_patch_package apply

Integration with Makefile #

rebuild:
	flutter clean
	flutter pub get
	dart run ft_patch_package apply

Patch file format #

Patch files use the <package>+<version>.patch naming convention:

patches/
├── health+13.3.1.patch
├── camera+0.10.6.patch
└── ...

Paths inside patch files use portable a/ and b/ prefixes (no machine-specific paths).

Features #

  • Portable patches - No machine-specific paths. Works on any developer's machine.
  • Version-aware - Matches exact package version from filename.
  • Idempotent - Running apply multiple times won't break anything.
  • Version mismatch warnings - Alerts when cached version differs from patch version.
  • Legacy support - Works with unversioned package.patch filenames too.

Improvements over patch_package #

Issue patch_package ft_patch_package
Portable paths Machine-specific absolute paths a/ b/ relative paths
External commands Requires diff and patch CLI tools Pure Dart — no external dependencies
Version matching First regex match (wrong version) Exact version from filename
Cross-platform Fails on Windows without GNU tools Works on Windows, macOS, Linux
Terminal output developer.log() (invisible) print() with colors
Idempotent apply Fails on re-apply Detects and skips
Security No path validation Path traversal prevention

License #

MIT

0
likes
140
points
262
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Patch Flutter & Dart packages like React Native's patch-package. Create, store, and auto-apply patches to pub dependencies after pub get. Fix bugs in third-party packages without forking.

Repository (GitHub)
View/report issues

Topics

#patch #patch-package #diff #dependency-management #cli

License

MIT (license)

Dependencies

path

More

Packages that depend on ft_patch_package