📚 Encyclopedia

Flutter & Mobile · updated 2026-10-13

Zero layout shift for network images in Flutter (dimensions in the URL)

flutterimageslayout-shiftplaceholdersmarkdownperformance

Images in user-written markdown arrive with no size, so a feed or post jumps as each one loads. TLDR fixed this without any server or schema change by putting the pixel dimensions into the image URL's fragment at upload time: https://api.../uploads/abc.png#w=1080&h=1350. The renderer reads the fragment, reserves the exact box, and the image fades into it.

Write side (at upload)

Why a fragment: it never reaches the server (no API change, cache keys unchanged), it survives in stored markdown, and Uri.parse keeps it out of download requests.

Read side

The compatibility trap

Any code that infers type from the URL must strip the fragment first. The filename helper saw png#w=... as the extension, failed the image check, and rendered the image as a generic file card. Fixed in the same release, but older Android builds still in the wild showed every new image as a file card until they updated. Web always runs the latest build; sideloaded APKs do not. When you change a URL format, check what old clients do with it.

List cards show a 56 dp thumbnail fetched from a fixed-size server thumbnail route rather than the original; see Accepting and serving user uploads safely from a private bucket.

See also

Linked from

Sources: tldr memory (release-v1.48.x, feature-post-thumbnails), post #1605