Questions tagged [flutter-bloc]

For questions relating to the "flutter_bloc" package for the Flutter framework. Use this tag in combination with the general [flutter] tag. If your question applies to Flutter more generally, use the [flutter] tag only.

This tag should be used for any questions regarding the flutter_bloc package for the Flutter framework.

flutter_bloc is a package implementing the BloC pattern for Flutter, specifically the BlocProvider and BlocBuilder classes.

To get started, you can read through the README document on GitHub.

932 questions
0
votes
0 answers

How can pass parameter to flutter BLoc?

I'm trying to pass parameters to a bloc event following the bloc pattern for set the default counter. I have found this question before, but that is doesn't work. Flutter BLoc pass parameters Flutter BLoC - How to pass parameter to…
0
votes
1 answer

FlutterBloc react to Blocs's initial state

How can I make my bloc react to the bloc's initial state. In the example im trying to log something on the blocs initial state but nothing happens. It only prints the blocs constructor but not the print statement from facilityIntial class…
0
votes
1 answer

Flutter BLoC BlocProvider.of() called with a context that does not contain a Bloc of type

Similar to this thread, so far no solution was relevant. I get the following error: BlocProvider.of() called with a context that does not contain a Bloc of type CategoryBloc. The only widget: class _TestWidgetState extends State { …
JayDew
  • 41
  • 1
  • 6
0
votes
1 answer

Adding event does not update BlocBuilder

I'm making an api call using the flutter_bloc pattern when a page loads for the first time. I'm adding the event in initState and it all works fine. I'm also trying to add a refresh button. And Im doing the exact same thing as I do in the initState.…
flutter
  • 6,188
  • 9
  • 45
  • 78
0
votes
2 answers

Bloc listener not invoked without a delay

I have defined the following cubit. @injectable class AuthCubit extends Cubit { final IAuthService _authService; AuthCubit(this._authService) : super(const AuthState.initial()); void authCheck() { …
Vinayak
  • 33
  • 2
  • 5
0
votes
1 answer

create an instance of Bloc by BlocProvider in initState in flutter

is it a good practice to initialize and create instance of Bloc in InItState() method in statefulWidget? or not, and why, thank you: LoginBloc loginBloc; @override void initState() { loginBloc = BlocProvider.of(context); …
Osama Mohammed
  • 2,433
  • 13
  • 29
  • 61
0
votes
1 answer

problem in adding event in the bloc in flutter_bloc

I am using Flutter_bloc package to make a phone auth in flutte, everything work good, but my question is about adding events to the bloc, for example in my application, when i click on button like this code below, the event added to my loginBloc,…
Osama Mohammed
  • 2,433
  • 13
  • 29
  • 61
0
votes
2 answers

show alert on cubit state in flutter

I know we can return different widgets on certain state of cubit, but how can we show an alert or other interactions on states: BlocBuilder ( builder: (context, LoginState loginState) { if (loginState is LoginInitial)…
SinaMN75
  • 6,742
  • 5
  • 28
  • 56
0
votes
0 answers

Same flutter_bloc for two sceens

This is the use case, I have invoice list and each invoice have list of item , flutter_bloc:6.0.0 is used When navigating to Invoice to Details , error will occured This is State Classes/ Bloc
0
votes
2 answers

Navigation to a different instance of an existing page

I'm dealing with a scenario where I have an Apartment page (StatefulWidget) and on this page, I also have a list of "similar apartments". When the user clicks on any of the similar apartments, they are Navigateed to a different instance of Apartment…
Sam Ramezanli
  • 998
  • 9
  • 20
0
votes
1 answer

Bloc - Is it possible to yield states for a previous page in the navigation stack?

I have a BlocBuilder which handles building widgets depending on the yielded state for my dashboard page. body: BlocBuilder( builder: (context, state) { print(state); if (state is…
Sam
  • 348
  • 1
  • 10
0
votes
1 answer

add separate bloc for (Sign Out) functionality in flutter_bloc

I have been using bloc pattern to create a login feature in my flutter application, and i have used the (flutter_bloc) plugin>>>> everything work good, but my question is should i create a separate bloc for (logout) or not, in my case i just add the…
Osama Mohammed
  • 2,433
  • 13
  • 29
  • 61
0
votes
1 answer

when to dispose a bloc in flutter?

In the below example we can see that the bloc is newly created in this stateful widget authenticationBloc = AuthenticationBloc(userRepository: userRepository); class App extends StatefulWidget { final UserRepository userRepository; App({Key…
Manas
  • 3,060
  • 4
  • 27
  • 55
0
votes
2 answers

Flutter Bloc does not update ui

I want to update the counter everytime user increments the cart but I wasn't able to do this because bloc does not call bloc builder. I am a newbie so please forgive me if I dont convey my problem correctly. I think this is happen because I am yield…
0
votes
1 answer

BlocProvider.of() called with a context that does not contain a Cubit of type

I'm sure there is something that I did wrong, but I cant seem to find what it is exactly. I have the following register_screen.dart class RegisterScreen extends StatelessWidget { static Route route() { return…
Lambasoft
  • 909
  • 2
  • 14
  • 33