CommunityImagegithub.com

KinwiseNZ-DevOps/flutter-optimiser

Audits and fixes Flutter image and asset performance: oversized source images, images decoded far larger than displayed, cacheWidth/cacheHeight, resolution-aware asset variants (arbitrary densities, not just 1x/2x/3x), duplicate density variants, and choosing SVG/vector vs raster for logos, icons, illustrations, photos and thumbnails. Use for high memory on image-heavy screens, slow scrolling with images, or large app assets. Do not convert assets just because another format could be smaller.

What is flutter-optimiser?

flutter-optimiser is a Claude Code agent skill that audits and fixes Flutter image and asset performance: oversized source images, images decoded far larger than displayed, cacheWidth/cacheHeight, resolution-aware asset variants (arbitrary densities, not just 1x/2x/3x), duplicate density variants, and choosing SVG/vector vs raster for logos, icons, illustrations, photos and thumbnails. Use for high memory on image-heavy screens, slow scrolling with images, or large app assets. Do not convert assets just because another format could be smaller.

Works with✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/KinwiseNZ-DevOps/flutter-optimiser/tree/HEAD/skills/flutter-perf-images-and-assets

Installed? Explore more Image skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Images and Assets

1. Detect

  • Flutter Inspector oversized-image diagnostics (where supported) flags images decoded larger than their display size.
  • DevTools memory view in profile mode for image cache growth.
  • Source dimensions and file sizes in assets/; compare to the largest size actually rendered.
  • Images inside scrolling lists: decoded repeatedly and at full size?

2. Fix oversized decoding

Order of preference:

  1. Resize the source asset to a sensible maximum for its use (preferred when the asset is under your control).
  2. cacheWidth / cacheHeight on Image/Image.network/ResizeImage to decode near display size, accounting for device pixel ratio. Set one dimension to keep aspect ratio.

Do not set cache sizes smaller than the displayed pixel size (blurry) and be careful where the same image is shown at several sizes.

3. Resolution-aware assets

Flutter picks the closest variant for the device pixel ratio from density-named folders (e.g. assets/2.0x/logo.png, assets/3.5x/logo.png).

  • Do not assume or enforce exactly 1x, 2x, 3x. Flutter supports additional densities.
  • Remove variants that are duplicates with no visual or size benefit; add a variant only where the one-size-fits-all asset is demonstrably too large or too soft.
  • Keep the declared asset path and variant folders consistent with pubspec.yaml conventions in the Flutter assets docs.

4. Choose the right asset type

AssetEvaluate
Logos, simple illustrationsVector/SVG suitability
IconsFlutter icon fonts or vector implementation
GradientsNative Flutter rendering (LinearGradient) rather than raster gradient images
PhotosAppropriately sized raster
ThumbnailsDecode at thumbnail size
Complex artworkDecide from its actual characteristics

Converting only because another format is "theoretically smaller" is not a reason. Any SVG approach that adds a dependency needs justification under the no-unnecessary-dependencies rule in guardrails. Visual output must stay materially unchanged.

5. Verify

Before/after: peak image memory, decode sizes in the Inspector, scroll jank on image-heavy lists, and a visual side-by-side at target densities. Method: flutter-perf-profiling-and-validation.

Individual skills in this repo

This repo contains 1 individual skill — each has its own dedicated page.

Related Skills