It’s easy to emit() all the states in flutter bloc or cubit. Just do the below If you are using Cubit, then call the above code from inside a method() in your extended cubit class. If you are using BLoC, then call the above code from inside event() in your extended BLoC class. Inside the…
Category: BLoC & Cubit
Flutter MultiBlocProvider With HydratedBLoC
Learn about flutter MultiBlocProvider with HydratedBLoC. To use them together, we need install them both Your bloc or cubit must extend HydratedBloc or HydratedCubit to do it. They both need to store data in the device in a directory. These directories could be created by the app. For this, we need to install another plugin….
Flutter BLoC update item in the list
We will learn how to update flutter bloc item in the list. First then you have to know that when you are creating a bloc or cubit using flutter_bloc, you have to create state classes and as you extend bloc or cubit, then you have mention the type of the state class in a List….
How to Use Getx and BLoC Together
Here, we will learn how to use Getx and BLoC together for our dummy flutter app. We will use Getx for routing and BLoC for state management. The real magic happens here The above code uses BlocProvider as wrapper for state management. Inside it we inject our bloc (CounterBlocs) and then in the child we…
Flutter HydratedCubit A Cubit And BLoC State Management Package
HydratedCubit A specialized Cubit which handles initializing the Cubit state based on the persisted state. This allows state to be persisted across application restarts. With HydratedCubit you can load JSON data and store JSON data locally. Your HydratedCubit class may look like this Since you want to manage storage using HydratedCubit, your Cubit class must…
Getx or BLoc for Flutter?
Getx is much easier and beginners friendly. With Getx you just need to know about some basic concept like GetBuilder, Obx, obs, Update() and some routing functions. And that’s all. With BLoc you must understand what is stream, sink, Provider and things like that. But these things are hard for beginners to grasp and it…