Performance

Flutter Performance Optimization: A Complete Guide

UK
Usman Khan
Sep 18, 2024
8 min read
Flutter Performance Guide
Back to Blog

Flutter apps are fast by default, but "fast enough" isn't the same as "optimized." After shipping 150+ production apps, we've developed a systematic approach to performance optimization that ensures every app we deliver runs at a buttery smooth 60fps (or 120fps on supported devices). This guide shares our battle-tested techniques.

Understanding the Frame Budget

At 60fps, you have approximately 16.67 milliseconds to build and render each frame. At 120fps, that drops to 8.33ms. Every millisecond matters. The two main threads to worry about are:

If either thread exceeds the frame budget, you get jank — that visible stutter users hate.

1. Minimize Widget Rebuilds

The #1 performance issue we see in client codebases is unnecessary widget rebuilds. When setState() is called, the entire widget subtree rebuilds. Here's how to minimize the blast radius:

Use const Constructors

// BAD - rebuilds every frame
Widget build(BuildContext context) {
  return Column(
    children: [
      Text('Static Header'),
      Counter(count: count),
    ],
  );
}

// GOOD - Header widget is cached
Widget build(BuildContext context) {
  return Column(
    children: [
      const Text('Static Header'),
      Counter(count: count),
    ],
  );
}

The const keyword tells Flutter this widget never changes, so it skips rebuilding it entirely. In large widget trees, this single optimization can eliminate thousands of unnecessary rebuilds per second.

Push State Down

Instead of calling setState() at the top of a large widget tree, extract the changing part into its own widget with its own state. This limits rebuilds to only the widgets that actually changed.

2. ListView Optimization

Lists are where most performance problems surface. Here are the rules we follow:

ListView.builder(
  itemCount: items.length,
  itemExtent: 72.0, // Fixed height = huge performance win
  addAutomaticKeepAlives: false,
  itemBuilder: (context, index) {
    return ProductListTile(product: items[index]);
  },
)

3. Image Optimization

Images are often the biggest performance bottleneck. Our approach:

Image.network(
  imageUrl,
  cacheWidth: 300,  // Decode at 300px, not original 3000px
  cacheHeight: 200,
  fit: BoxFit.cover,
)

⚡ Quick Win

Adding cacheWidth and cacheHeight to just 10 images in a list view can reduce memory usage by 80% or more.

4. Animation Performance

Animations should run on the raster thread when possible. Tips:

5. Build Mode vs Profile Mode

Never measure performance in debug mode. Debug mode includes:

Always profile with: flutter run --profile

This gives you near-release performance with DevTools access for measurement.

6. Shader Compilation Jank

The first time Flutter renders a specific visual effect, it compiles the shader for it. This can cause a one-time stutter. The solution: warm up shaders during app startup.

// In main.dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // Warm up shaders
  await ShaderWarmUp().warmUpShaderCache();
  
  runApp(MyApp());
}

With Flutter's Impeller rendering engine (default on iOS, coming to Android), shader compilation jank is largely eliminated. But it's still worth knowing if you're targeting older Flutter versions.

7. Memory Management

Our Performance Checklist

Before every release, we run through this checklist:

  1. Profile mode testing on lowest-spec target device
  2. DevTools performance overlay shows no red bars
  3. No frame exceeds 16ms (or 8ms for 120Hz apps)
  4. Memory stays stable during extended use (no leaks)
  5. App size is optimized (tree shaking, deferred components)
  6. Network calls are batched and cached appropriately
  7. Images are resolution-appropriate and cached

Tools We Use

Performance isn't an afterthought — it's a feature. Users may not notice a 60fps app, but they absolutely notice a 30fps one. Invest the time upfront, and your users (and app store ratings) will thank you.

🔍 Free Performance Audit

Struggling with app performance? We offer free 30-minute performance audits for Flutter apps. Book yours today.

Share this article:

Have an App Idea?

Let our team turn your vision into reality with Flutter.