The append-only AST trick that makes Flutter AI chat actually smooth
A new technique has been developed to enhance the performance of Flutter AI chat applications. This method utilizes an append-only Abstract Syntax Tree (AST) to prevent UI glitches during streamed responses. The solution has been packaged as 'streamdown', which significantly improves rendering speed and stability.
- ▪The append-only AST trick allows for smoother rendering in Flutter AI chat applications.
- ▪The solution addresses issues like code blocks flashing and scroll position breaking during streamed responses.
- ▪The 'streamdown' package is a drop-in replacement that is 188 times faster on chunked input.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3947184) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } jay limbani Posted on May 23 • Originally published at github.com The append-only AST trick that makes Flutter AI chat actually smooth #flutter #dart #ai #opensource — flutter_markdown re-parses the entire response string on every streamed token. The fix is an append-only AST with monotonic node IDs used as Flutter widget keys. I packaged it as streamdown — a drop-in replacement that's 188× faster on chunked input and produces zero visible flicker. Live on pub.dev today.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).