Posts

Mastering State Management in Flutter with Bloc: A Comprehensive Guide

Image
  Introduction State management is a critical aspect of building robust and maintainable Flutter applications. Flutter provides various state management options, and one of the most popular and powerful libraries for managing state is the  flutter_bloc  package. In this comprehensive guide, we will explore the fundamentals of state management with Bloc and provide a detailed example to help you get started. What is Flutter Bloc? flutter_bloc  is a library that leverages the BLoC (Business Logic Component) pattern to manage the state in Flutter applications. It provides a structured way to handle the flow of data and events within your app, making your codebase more organised and easier to maintain. Bloc separates the presentation layer from the business logic, promoting a clean and scalable architecture. Setting Up Your Flutter Project Before diving into the example, let’s set up a new Flutter project and add the  flutter_bloc  package to our dependencies. ...

Blocs Project Document

 Project File :     1 . PubSpec     2 . Configs:     3. Model     4.  Repositories     5. Services     6. Utilities     7.  Blocs     8. View     9. Widgets PubSpec: iconsax_plus : ^1.0.0 http : ^1.2.1 bloc : ^8.1.4 flutter_bloc : ^8.1.5 equatable : ^2.0.5 shared_preferences : ^2.2.3 logger : ^2.3.0 pinput : ^4.0.0 lottie : ^3.1.2 flutter_in_store_app_version_checker : ^1.6.1 flutter_sliding_toast : ^1.0.2 timezone : ^0.9.3 Configs: app_colors.dart: class AppColors{ static const Color seed = Color ( 0xff339966 ); static Color systemBg (context) => Theme. of (context). scaffoldBackgroundColor ; static Color error (context) => Theme. of (context). colorScheme . error ; //avatar bg static LinearGradient avatarBG = LinearGradient ( begin: Alignment. topLeft , end: const Alignment ( 0.80 , 0.80 ), colors: [ Colors. pink . shade50 , Colors....