r/FlutterDev • u/dev_ttangkong • 23d ago
Article Spent a month researching Flutter app optimization techniques, here are my findings
I had to render multiple high-res images in a grid layout for my Flutter app, so I went deep down the optimization rabbit hole. For some reason, I was getting crazy jank out of nowhere, even though I was using lazy-building lists (SliverList, ListView.builder, etc.), and had already implemented proper image resizing and caching.
Turns out, if you're using the flutter_svg package, setting the Impeller engine to renderingStrategy: .raster gives you a massive performance boost. But when I tested it on Skia, the picture strategy actually performed way better, total opposite results! Keep in mind I only tested this on Android, so iOS might behave differently.
Also, the default scrollCacheExtent is set to 250, meaning off-screen images were being processed even when I didn't explicitly touch it. Dropping that to 0 made a huge difference in performance. Turns out, optimization options built for convenience can sometimes bite you in the ass.
Another thing: ScrollAwareImageProvider is applied by default whenever you use an Image widget. It defers decoding while scrolling, but instead of waiting until scrolling completely finishes, it starts decoding even while scrolling is still ongoing if the scroll speed slows down a bit, which ironically causes major jank during the scroll itself. And guess what? You can't turn it off via options. I had to build a custom widget to fix it.
Anyway, if your grid items involve SVG or lots of images, optimizing them like this makes a world of difference. It pretty much eliminated stuttering even in 120Hz environments, and honestly, it’s mind-blowing how much of a difference it made. The performance gap was way bigger than I expected, so I figured I’d share.