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
7
votes
0 answers

How to work with flutter_bloc 8+, go_router +6 and refreshListenable

I'm using go_router for navigation and flutter_bloc for my state management. I would like to use refreshListenable and listen to my AuthBloC events in my GoRouter configuration, however, I don't have access to context in my GoRouter, and I would…
7
votes
2 answers

go_router and flutter_bloc: Unhandled Exception: No GoRouter found in context

I have wrapped the MaterialApp with a BlocProvider / BlocListener I get an error "Unhandled Exception: 'package:go_router/src/router.dart': Failed assertion: line 280 pos 12: 'inherited != null': No GoRouter found in context" from the Listener…
fvisticot
  • 7,936
  • 14
  • 49
  • 79
7
votes
3 answers

Flutter - Cant find bloc in the parent tree when using showDialog

Im using Flutter and flutter_bloc for a small app, and i used MultiBlocProvider to use multiple BlocProviders that i need in the main home page, and under the home page, there is a MainWidget, which can access the given Bloc easily by:…
RedZ
  • 857
  • 1
  • 13
  • 25
7
votes
1 answer

Do I need to dispose cubit instances?

I am new to flutter and bloc. As a matter of fact, I have just recently started using cubit. For learning purposes, I have created a simple app in which I use cubit for bloc functionality. In all the examples I found online, they suggest disposing…
johnweak
  • 73
  • 1
  • 3
7
votes
1 answer

Bloc initial state is not emitted anymore

I have a bloc that listens to another bloc. After updating flutter_bloc package to version 6.0.2, the listener won't call anymore in the initial state. class BlocA extends Bloc { final BlocB blocB = ...; ... blocA.blocB.listen((state) { …
Hamed
  • 5,867
  • 4
  • 32
  • 56
7
votes
2 answers

Flutter: How do I pop dialog as well as current page?

Below is the code. Navigation to Login page, from Home page ElevatedButton( onPressed: () => Navigator.of(context, rootNavigator: true) .push(MaterialPageRoute( fullscreenDialog: true, …
ronbm
  • 147
  • 2
  • 8
7
votes
1 answer

dispose in flutter bloc

On the code below, profileBloc is initialized in EditProfileScreenState's didChangeDependencies() method. Should we be calling dispose method on EditProfileScreenState class to dispose the profileBloc ? If so , how should the profileBloc method be…
anandasubedi
  • 441
  • 1
  • 6
  • 17
7
votes
2 answers

Modal Bottom Sheet and Bloc

I get the following error when I run code similar to the below code: BlocProvider.of() called with a context that does not contain a Bloc. To replicate BlocProvider( create: (context) => getIt() child:…
Gerry
  • 1,159
  • 1
  • 14
  • 29
7
votes
1 answer

How to change state of individual list items using bloc flutter?

How to change the widgets in a list item in flutter using bloc pacakage. Should i use BlockBuilder or listener on the whole ListView.builder or only the individual items. It would be nice if u share an example or tutorial. eg If i have a checkbox i…
Harshvardhan R
  • 407
  • 2
  • 7
  • 12
7
votes
1 answer

How to correctly use BlocListener and BlocProvider in Flutter App

I am using flutter_bloc 4.0.0 in my Flutter App, I used the example from Felix Angelov (https://medium.com/flutter-community/firebase-login-with-flutter-bloc-47455e6047b0) on implementing a sign in or login flow using the bloc pattern. It was…
K.chim
  • 868
  • 2
  • 14
  • 25
6
votes
2 answers

How to pass a bloc to another screen using go_router on flutter

On Flutter I would like to pass a local bloc to another screen. This is how I used to pass a bloc to a new route when using the default navigator. Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) => …
Abdi mussa
  • 171
  • 11
6
votes
1 answer

Can i call cubit from another cubit?

i'm working on an application that uses cubits, to manage the state. Very often when i need to make an api request i need to get my current localization (handle possible exceptions) and then send it to backend. So i guess i should use cubit for the…
6
votes
4 answers

( Flutter Bloc ) doesn't conform to the bound 'StateStreamable' of the type parameter 'B'

why am i getting the error? I couldn't find the reason. I'll be happy if you can help me. error screen You can check my issue on github
Serkan Ağca
  • 155
  • 1
  • 6
6
votes
1 answer

Flutter bloc new version deprecated mapEventToState

I have a bloc hierarchy, where in the child bloc's mapEvenToState I used super.mapEventToState. In the newer version of the bloc package, mapEventToState is deprecated. What should I use instead of super.mapEventToState? I know about on, but…
Errr
  • 65
  • 1
  • 4
6
votes
1 answer

Flutter - How can I pass a Bloc as a parameter in a reusable Widget?

I'm building a login page, and I have created what I intend to be used as a fully dynamic TextField widget. I now need to create 2 instances of that widget (email and password inputs) and send parameters for hintText, errorText, and then my…
solacking
  • 317
  • 2
  • 9
1 2
3
62 63