Skip to content

impatelravi/flutter_poc_bloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poc_bloc

BLoC (short for Business Logic Component) is a design pattern in Flutter used to separate business logic from UI. It helps manage and organize state and event handling in a clean and scalable way, especially in large applications.


🔧 Key Concepts of BLoC:

  1. Event: An action triggered by the user (e.g., button press, text input).

  2. State: The UI state that should be shown in response to events.

  3. BLoC: A component that:

    • Takes in Events
    • Processes logic
    • Emits new States to update the UI

📦 Common BLoC Tools:

  • flutter_bloc: A package that provides easy-to-use BLoC architecture.
  • BlocBuilder: Widget that rebuilds UI based on new states.
  • BlocProvider: Makes a BLoC available to the widget tree.

🧠 Example Use Case:

Imagine a counter app:

  1. Event: IncrementCounter
  2. State: CounterState(count: x)
  3. BLoC: Handles the event, updates the count, emits a new state
  4. UI: Uses BlocBuilder to listen to state changes and rebuild

✅ Why Use BLoC?

  • Promotes clean architecture
  • Encourages testable and reusable code
  • Ideal for scaling apps with complex logic and multiple screens
  • Reactive: BLoC works well with Streams, making state management dynamic

🚫 Downsides:

  • Can feel boilerplate-heavy
  • Might be overkill for small apps or simple widgets

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors