Why should you use const constructors whenever possible?
Const widgets are compile-time constants. Flutter knows they never change and skips them during rebuilds.
Minimize unnecessary rebuilds for smooth 60fps apps
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
Unnecessary widget rebuilds are the number one cause of jank in Flutter apps. Every time a parent widget calls setState, Flutter walks the widget tree and rebuilds all descendant widgets. If your tree is large and most of it has not changed, that wasted work adds up and can push frame rendering past the 16 millisecond budget needed for smooth 60 frames per second. The good news is that Flutter gives you several tools to minimize rebuilds. Const constructors tell the framework to skip a widget entirely because it can never change. Extracting small widgets limits the scope of a rebuild to only the subtree that actually changed. Lazy builders like ListView.builder create items on demand instead of all at once. RepaintBoundary isolates expensive paint operations so they do not force siblings to repaint. Mastering these techniques is the difference between an app that feels fluid and one that stutters on every scroll.
1// ── 1. Use const constructors ──2// BAD: Creates new Text every rebuild3Text('Hello')45// GOOD: Const: Flutter skips rebuild entirely6const Text('Hello')78// ── 2. Extract widgets to reduce rebuild scope ──9// BAD: Entire column rebuilds when counter changes10Column(11children: [12Text('Static header'), // rebuilds unnecessarily!13Text('$counter'), // this is what changed14const Icon(Icons.star), // rebuilds unnecessarily!15],16)1718// GOOD: Only CounterText rebuilds19Column(20children: [21const Text('Static header'), // skipped22CounterText(counter: counter), // only this rebuilds23const Icon(Icons.star), // skipped24],25)2627// ── 3. Use const widgets ──28class CounterText extends StatelessWidget {29final int counter;30const CounterText({super.key, required this.counter});3132@override33Widget build(BuildContext context) => Text('$counter');34}3536// ── 4. RepaintBoundary for expensive paints ──37RepaintBoundary(38child: CustomPaint(39painter: ExpensivePainter(), // isolate this from rest40),41)4243// ── 5. Use ListView.builder, not ListView ──44// BAD: Builds ALL items at once45ListView(children: items.map((i) => ListTile(title: Text(i))).toList())4647// GOOD: Only builds visible items48ListView.builder(49itemCount: items.length,50itemBuilder: (context, i) => ListTile(title: Text(items[i])),51)
Use Flutter DevTools (flutter pub global run devtools) to see the Widget Rebuild Counter. Enable 'Track widget rebuilds' to visualize which widgets rebuild on each frame.
Optimization starts with explicit rebuild boundaries:
Without boundaries, small interactions can trigger full-screen rebuild cascades.
Minimize unnecessary rebuilds for smooth 60fps apps. Widgets are reusable UI blocks. You combine them like LEGO pieces to build screens.
Think in architecture, reliability, and team-level maintainability.
Sketch the widget tree first, then code from top to bottom.
Most Flutter productivity comes from understanding layout rules and composing widgets cleanly.
Good widget composition is architecture at UI level, because it decides testability and reuse.
As your app grows, keep UI, state, and data responsibilities separate so each part stays testable and easier to modify.
Const widgets are compile-time constants. Flutter knows they never change and skips them during rebuilds.
ListView.builder lazily builds only the items currently visible on screen, saving memory and CPU.
RepaintBoundary creates a separate paint layer so when this subtree repaints it does not force siblings to repaint.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue