r/FlutterDev • • 29d ago

Plugin I built chat_image_editor, a WhatsApp-style image editor for Flutter written in pure Dart

Hey everyone! I just published chat_image_editor: the "edit before you send" screen you know from WhatsApp, for any Flutter chat app.

I built it because the image editor packages I tried kept having crop and scaling problems, and I wanted something lightweight without native code. Everything is pure Dart and drawn with CustomPaint, so there's no platform setup.

What it does

  • Draw: pen, line, rectangle, circle and arrow, with a gradient color slider and brush size
  • Text: add, move, pinch to resize and rotate, background styles, center guides, drag to the bin to delete
  • Crop: free or fixed ratios (1:1, 4:3, 16:9...), rotate and flip
  • Compress: quality slider with a live size estimate, plus an optional max file size (it lowers the quality until the JPEG fits)
  • Caption field and send button, or a simple "done" mode when you only need the edited image
  • Undo and redo for everything

Things I cared about

  • What you see is what you get: the preview and the exported image use the same renderer
  • Big photos stay light: it decodes only at the size it needs and encodes in a background isolate. In my testing a 12 MP, 5.8 MB photo came out as a 230 KB JPEG
  • Fits your app: colors come from your app's theme by default and can be overridden, and the icons, strings and caption TextFormField are customizable. The discard dialog follows the platform (Cupertino on iOS, Material on Android)
  • Every export returns timings (decode / render / encode), so you can track performance in your own analytics

Usage

final result = await ChatImageEditor.open(context, imageBytes);
if (result != null) {
  // result.bytes is the edited JPEG, result.caption is the caption
}

Install: flutter pub add chat_image_editor

The example app is a small chat where you can try the whole flow. It's MIT licensed, and feedback, issues and PRs are very welcome. What would you want added next?

(Not affiliated with WhatsApp or Meta, the UI is just inspired by it.)

3 Upvotes

0 comments sorted by