flutter_quill rich-text editor gotchas (markdown, IME, spell check, fonts)
flutterflutter_quillmarkdownimeandroidedge-to-edgespell-checkfonts
TLDR's composer is a WYSIWYG markdown editor built on flutter_quill 11 with markdown_quill for
Delta to markdown conversion and a custom compact toolbar. These are the traps it hit.
Android: typing always appends at the end (IME desync)
On Android 15/16, tapping into the middle of text and typing inserted at the end. Cause:
flutter_quill (up to 11.5.1) skips updateRemoteValueIfNeeded() whenever its keyboard-visibility
plugin says the keyboard is hidden. That plugin's heuristic (getWindowVisibleDisplayFrame
< 0.82 of the screen) is permanently false under edge-to-edge mode, which the app enables and
Android 15+ enforces. The IME keeps a stale end-of-text cursor.
Workaround in main.dart, before runApp:
KeyboardVisibilityTesting.setVisibilityForTesting(true);
It is sticky and puts quill in the forced-visible mode it uses on desktop and in tests. Remove once
upstream fixes the gate, and do not trust flutter_keyboard_visibility* detection anywhere else in
an edge-to-edge app.
Controller and markdown round-tripping
- Listen with
_controller.addListener, notdocument.changes; the stream breaks when the document is replaced. - Track the last Delta and emit
onChangedonly when content changed (selection moves also fire). - Track the last external value to avoid a feedback loop (parent
setStatetodidUpdateWidgetto document replace). On a real external change, dispose and recreate the controller rather than swapping the document, to avoid stale listeners. - Inserting raw markdown such as
as text gets its brackets escaped byDeltaToMarkdown. InsertBlockEmbed.image(url)for images and aLinkAttribute(url)for files, and give the editor a custom image embed builder (size limits, rounded corners, dark-mode error).
Spell check after flutter_quill 11
The built-in SpellCheckConfiguration was deprecated in 10.7.1 and removed in 11. Replacement:
simple_spell_checker + an English dictionary package (discontinued on pub.dev but working), a
custom inline attribute spell-error rendered by customStyleBuilder as a red wavy underline.
- Two passes over the Delta: first find code-block line ranges (the code-block attribute sits on the
\n op, not the text ops), then check words in text ops, skipping inline code, links and code
blocks. Handle contractions with and without apostrophes.
- Debounce 500 ms and set a suppress flag while applying attributes, or applying them triggers
another check.
- Strip the attribute before converting to markdown, so it never leaks into saved posts.
- Copy the dictionary map (Map.from) before caching it; the package may invalidate its internal
map on dispose.
Changing the editor font
flutter_quill's DefaultStyles.getInstance derives from the ambient DefaultTextStyle, so wrapping
the editor in DefaultTextStyle.merge(style: TextStyle(fontFamily: 'X')) re-fonts paragraphs,
headings and the placeholder in one place; inline code keeps its hardcoded monospace. Characters the
font lacks fall back per character to the default font. (TLDR ships a handwritten font built from a
photo, see Turning a photo of handwriting into an OpenType font (Python pipeline).)
Emoji on Flutter web
CanvasKit's chromium variant strips emoji font support; use canvasKitVariant: "full" in a custom
flutter_bootstrap.js and load Noto Color Emoji at startup with loadFontFromList().
See also
- Flutter and Dart gotchas (collections, widgets, theming)
- Flutter web (renderers, SEO, performance, when not to use it)