Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Flutter #29 Optimize Cubit using buildWhen & listenWhen

Автор: Ahmed saber

Загружено: 2025-08-27

Просмотров: 49

Описание:

🔹 Introduction

Quick intro: “When working with Bloc, you might notice buildWhen and listenWhen. Many devs ignore them, but they’re actually key for improving performance and controlling rebuilds and reactions.”

🔹 What is buildWhen?

Used inside BlocBuilder.

Decides when the UI should rebuild.

Signature: (previous, current) → bool.

If returns true → UI rebuilds.

If returns false → UI doesn’t rebuild.

👉 Example usage:

Login screen → you don’t want the whole screen rebuilding every time a loading state changes.

With buildWhen, you can rebuild only the widget that depends on the specific state.

⚡ Benefit: Prevents unnecessary widget rebuilds → better performance.

🔹 What is listenWhen?

Used inside BlocListener.

Decides when side effects should trigger (like navigation, showing SnackBars).

Signature: (previous, current) → bool.

If returns true → listener runs.

If returns false → listener ignored.

👉 Example usage:

You don’t want a SnackBar to show every time the state changes, only when there’s an error state.

With listenWhen, you can trigger the SnackBar only for error states.

⚡ Benefit: Prevents unnecessary SnackBars, dialogs, or repeated navigations.

🔹 Why are they Important for Performance?

Without buildWhen, every single state change triggers a rebuild, even if the UI doesn’t need it.

Without listenWhen, every single state change could trigger SnackBars or navigations → messy UX.

By filtering, you:

Optimize rebuilds.

Avoid useless side effects.

Keep the app responsive and smooth.

🔹 Best Practices

Use buildWhen to rebuild only the widgets that depend on the state.

Use listenWhen for one-time actions like navigation or showing messages.

Don’t overuse them → keep logic simple.

🔹 Closing

Recap: “buildWhen = control UI rebuilds, listenWhen = control side effects. Both give you cleaner code and better performance.”

End with: “Don’t ignore them—use them smartly!”

Flutter #29 Optimize Cubit using buildWhen & listenWhen

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Flutter #28 Firebase Auth (Email & Password) Repo & Cubit States

Flutter #28 Firebase Auth (Email & Password) Repo & Cubit States

Flutter #21 State Management with Cubit 01 | Cubit, States, Emit, BlocProvider & BlocBuilder

Flutter #21 State Management with Cubit 01 | Cubit, States, Emit, BlocProvider & BlocBuilder

Progress 2: Building The HomeScreen

Progress 2: Building The HomeScreen

1458. Max Dot Product of Two Subsequences| Leetcode | Hard| Daily challenge | Streak

1458. Max Dot Product of Two Subsequences| Leetcode | Hard| Daily challenge | Streak

Javascript - Error Handling nədir? | Try–Catch və Debugging

Javascript - Error Handling nədir? | Try–Catch və Debugging

Flutter #22 Cubit 02 | BlocListener & BlocConsumer Explained

Flutter #22 Cubit 02 | BlocListener & BlocConsumer Explained

FERRAN ŁAMIE KOD, A YAMAL GASI ŚWIATŁO! CZY ONI JESZCZE KIEDYŚ PRZEGRAJĄ? | SKRÓT

FERRAN ŁAMIE KOD, A YAMAL GASI ŚWIATŁO! CZY ONI JESZCZE KIEDYŚ PRZEGRAJĄ? | SKRÓT

Wyjaśniamy o co chodzi z Grenlandią. Czy naprawdę może wybuchnąć wojna USA-Dania?

Wyjaśniamy o co chodzi z Grenlandią. Czy naprawdę może wybuchnąć wojna USA-Dania?

Mrozu feat. Julia Pietrucha - Anioły (Pojedynek - official promo video)

Mrozu feat. Julia Pietrucha - Anioły (Pojedynek - official promo video)

ГАЙД НА ТРЕЙД В СТИМЕ | ТРЕЙД СКИНОВ

ГАЙД НА ТРЕЙД В СТИМЕ | ТРЕЙД СКИНОВ

Stop Cham #1403 - Niebezpieczne i chamskie sytuacje na drogach

Stop Cham #1403 - Niebezpieczne i chamskie sytuacje na drogach

Flutter #24 AppValidator Class & Regex Matching

Flutter #24 AppValidator Class & Regex Matching

#679 Chcą powstrzymać Trumpa. Iran-państwa przeciw atakom, odezwa Rodriguez, Rada Pokoju Strefy

#679 Chcą powstrzymać Trumpa. Iran-państwa przeciw atakom, odezwa Rodriguez, Rada Pokoju Strefy

Python Basic Part 2: Operators & Logic

Python Basic Part 2: Operators & Logic

Flutter #27 Installing Firebase & FlutterFire CLI Step by Step

Flutter #27 Installing Firebase & FlutterFire CLI Step by Step

LeetCode Problem 1458 – Max Dot Product of Two Subsequences(08-01-2026)|DP + Recursion (Memoization)

LeetCode Problem 1458 – Max Dot Product of Two Subsequences(08-01-2026)|DP + Recursion (Memoization)

Flutter #15 – Figma ToDo App UI Setup | Core Structure, Shared Widgets & Utilities

Flutter #15 – Figma ToDo App UI Setup | Core Structure, Shared Widgets & Utilities

Prawdziwy Powód, Dlaczego Psy CIĘ LIŻĄ (Szokujące!)

Prawdziwy Powód, Dlaczego Psy CIĘ LIŻĄ (Szokujące!)

Flutter #26 SQL vs NoSQL Databases Explained | How Relations Work + Firebase Overview

Flutter #26 SQL vs NoSQL Databases Explained | How Relations Work + Firebase Overview

Leetcode :-  Weekly Contest 484 solved 3/4

Leetcode :- Weekly Contest 484 solved 3/4

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com