flutter-svg-engineering
Skill8 starsChanged 48 days agoMITView on GitHub
Design, implement, review, debug, test, migrate, secure, and optimize SVG rendering in production Flutter applications using flutter_svg and vector_graphics. Use whenever a Flutter task involves SvgPicture, SVG assets, remote/dynamic SVG, SVG theming or ColorMapper, BoxFit/layout/clipping, semantics or RTL, SVG caching, precompiled .vec assets, RenderingStrategy, SVG-heavy list performance, malformed/unsupported SVGs, network SVG security, or migration from older flutter_svg APIs—even when the user only asks why an SVG is blank, slow, wrongly colored, clipped, or failing on one platform.
In this repository70 other files it gives its agents.
- camerawesome-flutterSkill
- dart-args-production-cliSkill
- dart-flutter-equatable-engineeringSkill
- dart-flutter-ffi-systems-engineeringSkill
- dart-metaSkill
- document-camera-frameSkill
- document-scan-flutterSkill
- figma-to-flutter-expertSkill
- flutter-animations-production-engineeringSkill
- flutter-app-hardening-reverse-engineeringSkill
- flutter-app-icon-engineeringSkill
- flutter-application-security-engineeringSkill
- flutter-app-links-deep-link-engineeringSkill
- flutter-cachingSkill
- flutter-concurrency-memory-performanceSkill
- flutter-confetti-engineeringSkill
- flutter-dart-package-engineeringSkill
- flutter-design-system-from-design-mdSkill
- flutter-dio-cache-interceptor-engineeringSkill
- flutter-dio-engineeringSkill
- flutter-doc-scannerSkill
- flutter-drift-persistence-engineeringSkill
- flutter-expert-tipsSkill
- flutter-firebase-analyticsSkill
- flutter-firebase-core-engineeringSkill
- flutter-firebase-messagingSkill
- flutter-get-it-injectable-dependency-injectionSkill
- flutter-go-router-engineeringSkill
- flutter-hive-persistence-engineeringSkill
- flutter-image-performanceSkill
- flutter-image-picker-production-engineeringSkill
- flutter-lints-static-analysis-engineeringSkill
- flutter-local-notifications-production-engineeringSkill
- flutter-memory-leak-engineeringSkill
- flutter-mobile-developmentSkill
- flutter-motion-engineeringSkill
- flutter-multi-environmentSkill
- flutter-native-splash-engineeringSkill
- flutter-package-plugin-selectionSkill
- flutter-path-provider-production-storageSkill
- flutter-performance-jank-optimizationSkill
- flutter-permission-handler-engineeringSkill
- flutter-pinputSkill
- flutter-production-build-releaseSkill
- flutter-production-engineeringSkill
- flutter-production-loggingSkill
- flutter-pro-image-editor-engineeringSkill
- flutter-secure-storage-security-engineeringSkill
- flutter-sentry-engineeringSkill
- flutter-share-plus-engineeringSkill
- flutter-skeletonizer-engineeringSkill
- flutter-squadron-concurrency-engineeringSkill
- flutter-supabase-engineeringSkill
- flutter-ui-performance-engineeringSkill
- flutter-url-launcher-engineeringSkill
- flutter-video-player-production-engineeringSkill
- flutter-webview-production-engineeringSkill
- freezed-production-engineeringSkill
- html-to-flutterSkill
- hydrated-blocSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
75 rules. About 0 are common, 50 are distinctive, and 25 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈50
Distinctive · estimate
This author's own choices. Worth a look.
25
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 7
Use this skill to make SVG decisions from source ownership, visual semantics, layout constraints, cache identity, runtime cost, and trust …
- Very specific: line 12
Prefer Icon for equivalent standard Flutter iconography.
- Distinctive: line 13
Prefer bundled assets for stable application artwork tied to the app release.
- Distinctive: line 14
Keep SVG rendering in the presentation layer.
- Very specific: line 15
Use current SvgPicture/loader APIs and remove deprecated picture-cache/color-era APIs during migrations.
- Very specific: line 18
Use ColorFilter for intentional whole-picture tinting, ColorMapper for selective source-aware recoloring, and SvgTheme for SVG-authored …
- Distinctive: line 21
Treat source-byte/HTTP caching, compiled-vector caching, and live rendered-picture reuse as separate layers.
- Distinctive: line 22
Keep source, theme, loader, and mapper identity stable when cache reuse matters.
- Very specific: line 23
Never claim SvgPicture.network provides a complete persistent HTTP/offline cache policy.
- Very specific: line 24
Use an application network layer before SvgPicture.memory when remote SVG needs authentication, retries, cancellation, status/content …
- Very specific: line 25
Treat remote/user SVG as untrusted input.
- Very specific: line 26
Do not enable allowDrawingOutsideViewBox globally to compensate for malformed assets.
- Very specific: line 29
Keep .vec compiler/runtime versions compatible and retain SVG as the maintainable source of truth.
- Very specific: line 30
Use RenderingStrategy.raster only after profiling shows vector painting is expensive and display scale is sufficiently stable.
- Distinctive: line 31
Do not precache every vector.
- Distinctive: line 32
Use golden tests for visually sensitive upgrades, exporter changes, color-mapping changes, fit changes, RTL changes, and rendering-strategy …
- Distinctive: line 36
Read only the reference required for the current task:
- Distinctive: line 60
Search for legacy or risky patterns:
- Distinctive: line 76
Do not refactor until the current visual and caching behavior is understood.
- Distinctive: line 79
Use this default decision table:
- Distinctive: line 91
Do not use source file size as a proxy for render cost.
- Very specific: line 105
Prefer fetching through an application networking layer and rendering bytes when remote policy requires more than the convenience network …
- Very specific: line 106
Do not use dart:io File as a Flutter Web source model.
- Very specific: line 127
Never assume viewBox="0 0 100 100" means a 100×100 logical-pixel widget.
- Distinctive: line 134
Use directional alignment only when the alignment itself should follow text direction.
- Distinctive: line 135
Keep clipping minimal. Fix incorrect source view boxes instead of globally enabling out-of-view-box drawing.
- Distinctive: line 151
Do not globally tint a multicolor logo or illustration unless the intended design is monochrome.
- Very specific: line 154
Prefer source-aware rules using element ID/name/attribute when the same raw color has multiple meanings.
- Very specific: line 164
Use matchTextDirection: true only for direction-sensitive artwork such as chevrons/back-forward arrows.
- Distinctive: line 165
Test semantics and RTL when either affects product behavior.
- Distinctive: line 169
Treat a missing/invalid critical asset primarily as a development/build defect.
- Distinctive: line 172
When using authenticated or controlled remote SVG, validate transport/content in the network layer before presentation.
- Distinctive: line 173
Never log sensitive request headers, signed URLs, or arbitrary raw user SVG unless explicitly sanitized and required.
- Very specific: line 176
Do not assume flutter_svg is a browser SVG runtime.
- Distinctive: line 177
When an asset fails:
- Very specific: line 188
Do not convert actual UI text to image paths when Flutter text should remain accessible/selectable/localizable.
- Distinctive: line 191
Keep these layers distinct:
- Distinctive: line 206
Do not change global SVG cache size before measuring unique vector count, churn, and memory.
- Distinctive: line 210
When first-use parse/compile cost is visible:
- Distinctive: line 214
Test targeted warm-up only for highly likely next-use artwork.
- Very specific: line 215
Test precompiled .vec for bundled critical vectors.
- Distinctive: line 217
Do not preload the entire asset catalog.
- Distinctive: line 220
Consider precompilation when complex bundled SVG parsing/compilation appears in the critical path or many critical vectors appear …
- Very specific: line 225
Treat .vec as generated runtime artifact, not stable archival interchange format.
- Distinctive: line 226
Verify output visually, preferably with goldens for important artwork.
- Distinctive: line 227
Do not add build-pipeline complexity for tiny vectors whose runtime parse cost is negligible.
- Distinctive: line 230
Default to picture/vector rendering unless measurement shows a reason to change.
- Distinctive: line 231
Consider raster strategy when all are true:
- Distinctive: line 245
Do not set it globally.
- Very specific: line 251
prefer Icon when an equivalent glyph exists.
- Distinctive: line 252
avoid unnecessary semantics/clipping.
- Distinctive: line 256
avoid giant vectors per row.
- Distinctive: line 257
use simplified/raster thumbnails where appropriate.
- Distinctive: line 260
Do not assume SVG is cheap because each file is small.
- Distinctive: line 272
Avoid feeding unbounded unique dynamic strings/bytes into a long-running view without an application-level retention policy.
- Distinctive: line 273
When memory is high, inspect unique vector count, source-byte cache, rendered dimensions, raster strategy, retained screens, and the SVG …
- Distinctive: line 278
use HTTPS and normal Web security policy.
- Distinctive: line 282
keep parser/compiler dependencies current.
- Very specific: line 286
Do not describe flutter_svg as an XSS sanitizer or arbitrary-document security sandbox.
- Very specific: line 312
Create a design-system wrapper only when it enforces useful policy such as dimensions, semantics, tinting, or directionality.
- Distinctive: line 315
Use widget tests for:
- Distinctive: line 322
Use golden tests for:
- Distinctive: line 330
Use profiling, not golden tests, to prove performance.
- Distinctive: line 331
Do not hit production URLs from widget tests or use arbitrary sleeps for vector decode completion when deterministic test utilities are …
- Very specific: line 345
Remove theming first, then inspect source colors, ColorFilter, mapper rules, SvgTheme.currentColor, and light/dark asset selection.
- Distinctive: line 373
Do not retain performance complexity that did not improve the target metric.
- Very specific: line 379
Search legacy APIs such as direct color/colorBlendMode, old picture providers/caches, and old precache APIs.
- Distinctive: line 380
Read the supplied migration guidance in reference 01/03 and package changelog if current verification is requested.
- Distinctive: line 384
Run widgets, semantics, goldens, and performance checks appropriate to the changed behavior.
- Distinctive: line 385
Do not combine an API migration with unrelated visual/layout changes unless explicitly intended.
- Very specific: line 412
Read references/04-anti-patterns.md for the full supplied examples and reasoning.
- Distinctive: line 415
Before approving SVG-heavy production code, verify:
- Distinctive: line 417
Every bundled asset exists and is declared correctly.
- Distinctive: line 453
Before adding or optimizing SVG, answer:
- Distinctive: line 470
If those answers are unknown, inspect and measure before adding rendering complexity.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Flutter SVG Engineering
Use this skill to make SVG decisions from source ownership, visual semantics, layout constraints, cache identity, runtime cost, and trust boundaries—not from the .svg extension alone.
Operating rules
- Inspect the repository before changing SVG code: Flutter SDK,
flutter_svg,vector_graphics, compiler/runtime versions, platform targets, asset declarations, wrappers, tests, and existing network/cache layers. - Decide whether SVG is the correct rendering format before adding
SvgPicture. - Prefer
Iconfor equivalent standard Flutter iconography. - Prefer bundled assets for stable application artwork tied to the app release.
- Keep SVG rendering in the presentation layer; state/domain code should expose semantic state, asset identity, URL, or validated bytes—not Flutter widgets.
- Use current
SvgPicture/loader APIs and remove deprecated picture-cache/color-era APIs during migrations. - Give icons explicit dimensions and constrain asynchronous/dynamic vectors so loading cannot destabilize layout.
- Choose
BoxFit, alignment, clipping, and RTL mirroring from visual semantics, not defaults copied from another asset. - Use
ColorFilterfor intentional whole-picture tinting,ColorMapperfor selective source-aware recoloring, andSvgThemefor SVG-authored theme-relative values such ascurrentColor. - Preserve multicolor artwork unless the design explicitly calls for a monochrome treatment.
- Provide one accessible meaning for meaningful artwork; exclude decorative artwork from semantics.
- Treat source-byte/HTTP caching, compiled-vector caching, and live rendered-picture reuse as separate layers.
- Keep source, theme, loader, and mapper identity stable when cache reuse matters.
- Never claim
SvgPicture.networkprovides a complete persistent HTTP/offline cache policy. - Use an application network layer before
SvgPicture.memorywhen remote SVG needs authentication, retries, cancellation, status/content validation, persistent caching, telemetry, or input limits. - Treat remote/user SVG as untrusted input.
flutter_svgis a renderer/compiler pipeline, not a sanitizer. - Do not enable
allowDrawingOutsideViewBoxglobally to compensate for malformed assets. - Profile complex or repeated SVGs in profile/release-like conditions before selecting precompilation, raster rendering, or raster-image replacement.
- Precompile
.veconly when runtime SVG parse/compile cost is measurable or strategically important. - Keep
.veccompiler/runtime versions compatible and retain SVG as the maintainable source of truth. - Use
RenderingStrategy.rasteronly after profiling shows vector painting is expensive and display scale is sufficiently stable; validate memory and pixel quality. - Do not precache every vector. Warm only likely, latency-sensitive artwork with measured first-use cost.
- Use golden tests for visually sensitive upgrades, exporter changes, color-mapping changes, fit changes, RTL changes, and rendering-strategy changes.
- Preserve correctness, semantics, visual fidelity, and platform behavior before performance micro-optimizations.
Reference routing
Read only the reference required for the current task:
references/01-api-layout-theming-accessibility.md— read for format/source selection,SvgPictureAPIs, loaders, dimensions,BoxFit, clipping, theming,ColorMapper, semantics, RTL, errors, unsupported SVG features, and export guidance.references/02-caching-rendering-performance-security-platforms.md— read for cache layers, precaching,RenderingStrategy, lists, precompiled.vec, memory/startup/scrolling, network cache boundaries, untrusted SVG, Web, mobile, or desktop behavior.references/03-architecture-testing-debugging-profiling.md— read for design-system wrappers, presentation/state/DI boundaries, testing, goldens, debugging, and performance profiling.references/04-anti-patterns.md— read during review/refactoring when diagnosing common implementation mistakes.references/05-workflows-checklists-quick-reference.md— read when implementing from scratch, reviewing a repository, refactoring, preparing release, or running final checklists. For a package upgrade or broad audit, read references 01, 02, 03, then 05. Read 04 if the repository shows problematic patterns.
1. Inspect before editing
Record:
Flutter SDK:
flutter_svg:
vector_graphics runtime:
vector_graphics compiler/codec if used:
Targets:
Source types: asset / network / string / bytes / file / .vec
Existing wrappers/design system:
Network/cache layer:
Dynamic or untrusted SVG sources:
SVG-heavy screens/lists:
Golden/semantics/widget tests:Search for legacy or risky patterns:
SvgPicture
color:
colorBlendMode:
PictureProvider
PictureCache
precachePicture
allowDrawingOutsideViewBox
RenderingStrategy
ColorMapper
SvgPicture.network
SvgPicture.string
SvgPicture.memoryDo not refactor until the current visual and caching behavior is understood.
2. Decide whether SVG is the right format
Use this default decision table:
| Requirement | Default choice |
| Standard Material symbol | Icon |
| Custom scalable static icon/logo | SVG |
| Scalable static illustration | SVG, then profile if complex |
| Fixed-size complex static illustration | Profile SVG vs raster |
| Photograph | Raster image |
| Animated/interactive vector scene | Purpose-built animation solution |
| Procedural drawing | CustomPainter |
| SVG shell containing a huge bitmap | Render the raster content directly |
| Thousands of repeated tiny symbols | Compare Icon, simple/precompiled SVG, or raster based on evidence |
| Do not use source file size as a proxy for render cost. Geometry, gradients, clips, masks, embedded images, and render area matter. |
3. Choose the source API by ownership
Use:
bundled app/package artwork → SvgPicture.asset
simple public HTTP SVG → SvgPicture.network
owned raw markup → SvgPicture.string
already-fetched bytes → SvgPicture.memory
native local file → SvgPicture.file
precompiled vector → SvgPicture(AssetBytesLoader(...))
custom source/cache identity → custom BytesLoader only when justifiedPrefer fetching through an application networking layer and rendering bytes when remote policy requires more than the convenience network constructor can express.
Do not use dart:io File as a Flutter Web source model.
4. Stabilize layout before styling
For icons, normally set both dimensions:
SvgPicture.asset(
'assets/icons/search.svg',
width: 24,
height: 24,
fit: BoxFit.contain,
)For illustrations, use tight constraints such as SizedBox, AspectRatio, or a bounded parent. Keep placeholders/fallbacks at the same intended size when layout stability matters.
Distinguish:
SVG viewBox = internal vector coordinate system
Flutter constraints = rendered widget size
BoxFit = mapping between those spacesNever assume viewBox="0 0 100 100" means a 100×100 logical-pixel widget.
Fit decision
contain: show all artwork and preserve aspect ratio; default for icons/logos/illustrations.cover: fill bounds and accept crop; validate responsive crops.fill: distort aspect ratio; use only intentionally.fitWidth/fitHeight: use when one axis is authoritative and overflow/crop is acceptable.none/scaleDown: specialized natural-size behavior. Use directional alignment only when the alignment itself should follow text direction. Keep clipping minimal. Fix incorrect source view boxes instead of globally enabling out-of-view-box drawing.
5. Choose theming from artwork semantics
Use this order:
Preserve source colors if artwork is already correct
↓
Monochrome whole-picture tint → ColorFilter + BlendMode.srcIn
↓
SVG authored with currentColor/em/ex → SvgTheme
↓
Selective source palette replacement → ColorMapper
↓
Geometry/composition changes by theme → separate light/dark assetsDo not globally tint a multicolor logo or illustration unless the intended design is monochrome.
Stable ColorMapper
Because mapper identity participates in cache identity, use const mappers where possible or implement value equality for parameterized mappers. Do not recreate semantically identical identity-only mappers on every build if cache reuse is important.
Prefer source-aware rules using element ID/name/attribute when the same raw color has multiple meanings.
6. Preserve accessibility and directionality
For meaningful artwork, provide an accessible label or equivalent surrounding semantics. For decorative artwork:
excludeFromSemantics: trueFor an SVG inside an already labeled button, normally exclude the SVG's own semantics to avoid duplicate announcements.
Use matchTextDirection: true only for direction-sensitive artwork such as chevrons/back-forward arrows. Do not mirror logos, checks, clocks, maps, charts, or brand marks merely because the UI is RTL.
Test semantics and RTL when either affects product behavior.
7. Design failure behavior by source
Bundled assets
Treat a missing/invalid critical asset primarily as a development/build defect. Fix the asset declaration/path and keep tests that expose it.
Network/dynamic sources
Assume failure and malformed content are possible. Provide stable-size placeholder/fallback behavior when user experience requires it. When using authenticated or controlled remote SVG, validate transport/content in the network layer before presentation. Do not treat an HTML error page as valid SVG input. Never log sensitive request headers, signed URLs, or arbitrary raw user SVG unless explicitly sanitized and required.
8. Handle unsupported SVG at the asset pipeline
Do not assume flutter_svg is a browser SVG runtime. Verify current compiler support before declaring a feature supported or unsupported.
When an asset fails:
inspect/export source
→ prefer presentation attributes over fragile CSS where required
→ simplify unsupported filters/text features
→ remove redundant editor output
→ embed/source-control referenced images
→ convert decorative text to paths only when fidelity requires it
→ compare raster fallback or alternate renderer if necessaryDo not convert actual UI text to image paths when Flutter text should remain accessible/selectable/localizable.
9. Model caching correctly
Keep these layers distinct:
HTTP/CDN/browser/application byte cache
↓
SVG source bytes/string
↓
flutter_svg compiled-vector cache
↓
vector_graphics live rendered picture reuse
↓
optional rasterized representationA compiled-vector cache hit does not imply persistent network caching or offline behavior. Cache reuse can change when any relevant source/configuration changes, including URL, headers, asset/package, bytes/string, theme, mapper, loader, or bundle identity. Do not change global SVG cache size before measuring unique vector count, churn, and memory.
10. Optimize parsing and first use only when measured
Current source baseline uses a compile/decode pipeline rather than reparsing XML on every ordinary widget rebuild when cache identity is stable. When first-use parse/compile cost is visible:
- Confirm it in profile/release-like measurement.
- Stabilize source/loader identity.
- Simplify source geometry/export.
- Test targeted warm-up only for highly likely next-use artwork.
- Test precompiled
.vecfor bundled critical vectors. - Re-measure startup/transition latency and memory. Do not preload the entire asset catalog.
11. Use precompiled .vec deliberately
Consider precompilation when complex bundled SVG parsing/compilation appears in the critical path or many critical vectors appear immediately. Keep these invariants:
- SVG remains source of truth.
- Compiler and runtime/codec remain compatible.
- Regenerate
.vecoutputs after relevant vector-graphics upgrades. - Treat
.vecas generated runtime artifact, not stable archival interchange format. - Verify output visually, preferably with goldens for important artwork. Do not add build-pipeline complexity for tiny vectors whose runtime parse cost is negligible.
12. Choose rendering strategy from raster evidence
Default to picture/vector rendering unless measurement shows a reason to change. Consider raster strategy when all are true:
vector is complex
+ raster thread is measurably expensive
+ artwork is mostly static
+ rendered scale is stable enoughThen compare:
- raster duration;
- memory/image allocation;
- pixel quality under device pixel ratio and parent transforms;
- behavior during resize/scale/animation. Raster strategy can trade per-frame vector work for retained raster memory and can pixelate if later transformed beyond the rasterized scale. Do not set it globally.
13. Optimize SVG-heavy lists by workload
For repeated simple icons:
- reuse stable asset/source identity;
- keep dimensions bounded;
- prefer
Iconwhen an equivalent glyph exists; - avoid unnecessary semantics/clipping;
- prevent unrelated state changes from rebuilding an entire heavy list when profiling shows meaningful cost. For many unique complex illustrations:
- expect more compiled/live representations;
- avoid giant vectors per row;
- use simplified/raster thumbnails where appropriate;
- move full-detail vector rendering to detail views;
- profile fast scroll on representative hardware. Do not assume SVG is cheap because each file is small.
14. Bound memory and dynamic SVG churn
Account for:
source strings/bytes
+ application HTTP/disk/memory cache
+ compiled vector data
+ live pictures
+ rasterized images when raster strategy is usedAvoid feeding unbounded unique dynamic strings/bytes into a long-running view without an application-level retention policy. When memory is high, inspect unique vector count, source-byte cache, rendered dimensions, raster strategy, retained screens, and the SVG compiled cache separately.
15. Treat remote/user SVG as untrusted
For arbitrary or semi-trusted input, control the boundary before rendering:
- restrict trusted origins where possible;
- use HTTPS and normal Web security policy;
- enforce network timeouts/cancellation in the network layer;
- cap response/content size;
- validate expected response/content semantics where appropriate;
- keep parser/compiler dependencies current;
- reject pathological or unsupported input;
- bound application-level cache/history;
- provide fallback behavior.
Do not describe
flutter_svgas an XSS sanitizer or arbitrary-document security sandbox. On Flutter Web, browser CORS/mixed-content policy still applies.
16. Keep architecture boundaries clean
Prefer:
Domain/application state
↓
asset ID / URL / validated bytes / visual state
↓
Presentation widget
↓
SvgPictureFor authenticated remote artwork:
repository/network layer
↓
validated/cached Uint8List
↓
presentation
↓
SvgPicture.memoryInject a source repository when source retrieval is genuinely a dependency. Do not inject SvgPicture, and do not build SVG widgets in Cubits/Blocs/domain classes.
Create a design-system wrapper only when it enforces useful policy such as dimensions, semantics, tinting, or directionality. Avoid wrappers that merely mirror every SvgPicture argument.
17. Test behavior at the right layer
Use widget tests for:
- asset existence/render completion;
- fallback behavior;
- semantics;
- RTL behavior;
- theme variants;
- deterministic network-loader behavior with fake clients/source abstractions. Use golden tests for:
- brand-critical SVGs;
- fit/alignment/crop;
- light/dark variants;
ColorFilter/ColorMapperchanges;- package/compiler upgrades;
- precompiled vs runtime rendering;
- rendering-strategy changes. Use profiling, not golden tests, to prove performance. Do not hit production URLs from widget tests or use arbitrary sleeps for vector decode completion when deterministic test utilities are available.
18. Debug systematically
Blank or missing SVG
Check in order:
- asset/source path and declaration;
- error callback/parser diagnostics;
- finite nonzero constraints;
viewBoxand source bounds;- source fill/stroke/opacity;
- accidental tint/filter;
- unsupported construct/export style;
- clipping/fit.
Wrong color
Remove theming first, then inspect source colors, ColorFilter, mapper rules, SvgTheme.currentColor, and light/dark asset selection.
Clipped/stretched
Inspect parent bounds, BoxFit, view box, alignment, and clips. Do not enable drawing outside the view box before validating source bounds.
Remote failure
Inspect URL, HTTP status/body, authentication, CORS on Web, content type/actual bytes, offline state, and whether a backend error page is being parsed as SVG.
Slow scrolling/rendering
Profile before editing. Determine UI vs raster cost, unique SVG count, source complexity, rendered size, cache-key stability, rebuild frequency, clipping, and current rendering strategy.
High memory
Separate application source-byte cache, compiled-vector cache, live pictures, rasterized images, and screen retention.
19. Profile performance with one hypothesis at a time
Use this loop:
reproduce in profile/release-like mode
↓
classify UI/loading/compile/raster/memory cost
↓
check source complexity and cache identity
↓
change one contributor
↓
compare runtime SVG / simplified SVG / .vec / raster strategy / raster image
↓
measure memory and visual quality
↓
keep only demonstrated improvementsDo not retain performance complexity that did not improve the target metric.
20. Migrate older flutter_svg code safely
Before upgrading:
- Record locked
flutter_svg,vector_graphics, and compiler/codec versions. - Capture goldens for visually sensitive assets.
- Search legacy APIs such as direct
color/colorBlendMode, old picture providers/caches, and old precache APIs. - Read the supplied migration guidance in reference 01/03 and package changelog if current verification is requested.
- Replace deprecated color behavior with an equivalent
ColorFilterwithout changing blend semantics unintentionally. - Preserve dimensions, fit, alignment, semantics, RTL, and source ownership during loader refactors.
- Regenerate
.vecassets when required by compiler/runtime changes. - Run widgets, semantics, goldens, and performance checks appropriate to the changed behavior. Do not combine an API migration with unrelated visual/layout changes unless explicitly intended.
Anti-pattern gate
Reject or refactor code that does any of the following without a documented reason:
- generates a huge SVG string every build;
- hosts stable release artwork remotely;
- leaves async/dynamic vectors unconstrained and causes layout shift;
- globally tints multicolor artwork;
- introduces deprecated color APIs;
- string-replaces SVG markup every build to theme it;
- precaches the full SVG catalog;
- assumes network SVG equals offline HTTP cache;
- omits fallbacks for important remote/dynamic SVG;
- uses SVG for standard built-in icons without a reason;
- renders giant unique illustrations in every list row;
- adds redundant clipping;
- mirrors all vectors in RTL;
- adds semantics to decorative vectors or omits semantics for meaningful ones;
- ships huge raster payloads inside an SVG shell;
- relies on unsupported filters instead of fixing/exporting the asset;
- creates
SvgPicturein business/state logic; - adds a wrapper that only mirrors the entire package API;
- judges runtime efficiency from file byte size alone;
- accepts arbitrary remote/user SVG with no resource/security policy;
- copies bytes every rebuild;
- recreates identity-only
ColorMapperobjects and defeats cache reuse; - globally enables
allowDrawingOutsideViewBox. Readreferences/04-anti-patterns.mdfor the full supplied examples and reasoning.
Production readiness gate
Before approving SVG-heavy production code, verify:
Correctness and visual fidelity
- Every bundled asset exists and is declared correctly.
- Current source features are supported or intentionally transformed/fallback-rendered.
- Bounds, fit, crop, alignment, and clipping are verified on relevant screen sizes.
- Multicolor/brand artwork is not accidentally tinted.
- Light/dark variants are visually correct.
.vec/raster-strategy output is visually compared where used.
Accessibility and RTL
- Meaningful images have an accessible equivalent.
- Decorative images are excluded from semantics.
- Controls expose one clear semantic label.
- Directional artwork mirrors intentionally; nondirectional/brand artwork does not.
Reliability and security
- Dynamic/network sources have appropriate failure fallback.
- Advanced HTTP/auth/cache/validation policy lives outside the convenience renderer where needed.
- Flutter Web CORS/HTTPS behavior is accounted for.
- Arbitrary SVG is not blindly trusted.
- Response/resource limits are considered for user-controlled sources.
- Parser/compiler stack is kept compatible/current under the repository's upgrade policy.
- Secrets are not placed in SVG URLs/logs/markup diagnostics.
Performance and memory
- Complex/repeated vectors are profiled on representative workloads.
- Cache keys remain stable where reuse matters.
- Dynamic SVG churn is bounded.
- Large list/grid workloads remain smooth.
- Preloading is targeted.
- Precompiled vectors are justified by measured parse/startup cost.
- Raster strategy is justified by measured raster benefit and acceptable image memory/quality.
- SVG cache/source byte cache sizes are intentional.
Testing and migration
- Important assets have widget or visual coverage.
- Semantics, theme, RTL, and error paths are tested where relevant.
- Visually sensitive package/export/rendering changes have goldens.
- Deprecated APIs are removed rather than hidden behind compatibility wrappers.
.vecartifacts are regenerated with compatible tooling when dependencies change.
Final rule
Before adding or optimizing SVG, answer:
Is SVG the right format?
What owns the source?
Is the source trusted?
Does the current compiler support it?
What Flutter bounds and BoxFit are required?
How should color/theme semantics work?
What semantics and RTL behavior are required?
What can fail and what is the fallback?
Which cache layer is responsible for what?
Will cache identity remain stable?
Is the vector actually expensive under measurement?
Would simplification, .vec, raster strategy, or a raster asset be better?
How will correctness, visual fidelity, memory, and performance be verified?If those answers are unknown, inspect and measure before adding rendering complexity.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

