FlutterBegin: post #946 — TG.ME

🔥 Flutter Tip: Prevent Unnecessary Rebuilds with const Selectors in Riverpod / Bloc

Stop passing entire state objects into your build methods. When dealing with complex state, observing the full object triggers rebuilds on every field change, even ones your sub-widget doesn't care about.

Bad Approach (Triggers rebuild on any UserState change):

Dart
// Rebuilds even if only user.email changes!
final name = ref.watch(userProvider).name;
return Text(name);

Pro Approach (Rebuilds ONLY when name changes):

Dart
// Selects only the specific value
final name = ref.watch(userProvider.select((u) => u.name));
return Text(name);

💡 Why it matters:

select() acts as an internal comparator memoizing state properties.

Reduces frame drops (jank) in heavy tree structures, especially during high-frequency stream updates or background syncs.

@FlutterBegin.
❤2👍1
August 8, 2026 266 1