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
1 answer

Why are the objects instantiated differently in these BLOC events?

I am following Felix Angelov's tutorial "https://www.hidigital.io/blog/2020/06/flutter-login-tutorial-with-flutter-bloc" on Flutter Bloc pattern. Why is the class for AuthenticationEvent instantiated like this: import…
Manas
  • 3,060
  • 4
  • 27
  • 55
0
votes
1 answer

choosing the correct flutter bloc widget that doesn't depend on states

Which flutter bloc widget to use if i want to add an item to list in bloc class and automatically update the UI on the basis of items of that list without the use of states (without yielding a state upon addition of new item to the list)? In another…
Manish Wagle
  • 456
  • 2
  • 5
  • 12
0
votes
1 answer

Update of the not immediate state in Example Counter - BloC Flutter

My pubspec.yml: bloc: ^4.0.0 flutter_bloc: ^4.0.0 equatable: ^1.2.5 I created my CounterBloc: class CounterBloc extends Bloc { @override int get initialState => 0; @override Stream mapEventToState(event)…
0
votes
1 answer

Issue State not updating in Flutter Bloc

I'm using the Bloc package to update my widgets on a Flutter app. I try to update a variable which is a List of favorites. For that I'm getting the state and modifying it to the new value and then I yield the new one(state). The result is cannot see…
Luciano
  • 13
  • 7
0
votes
2 answers

How to push and pop one widget from another widget (Transition of B from A)

Suppose I have two Widget A and B. A listens for event changes. And Event type is Connectivity status. A --> One Widget (separate screen) B --> Another Widget (separate screen) Event Type | --> INTERNET_CONNECTED --> INTERNET_NOT_CONNECTED I…
Purushotam Kumar
  • 1,002
  • 2
  • 13
  • 23
0
votes
1 answer

Either inside BlocProvider is not returning value

I want to use Either to store result in BlocBuilder. According to result I want to show specific Widget. But using Either will throw exception that BlocBuilder returned null. I debugged that code and fold branch was called correctly, so it should…
martin1337
  • 2,384
  • 6
  • 38
  • 85
0
votes
2 answers

Consumer not reacting to changes in ChangeNotifier in profile/release builds

I have a class which extends from ChangeNotifier, it manages the state of one widget: MainSection _section = MainSection.SETUP; MainSection get section => _section; set section(MainSection value) { _section = value; // some code …
svprdga
  • 2,171
  • 1
  • 28
  • 51
0
votes
1 answer

Wait for the Bloc to finish in Flutter

Future loginWithEmail( String email, String password, ) async { await FirebaseAuth.instance.signInWithEmailAndPassword(email: email, password: password); final data = await request('fetch-user'); final user = UserV1.fromJson(data); …
Oliver Dixon
  • 7,012
  • 5
  • 61
  • 95
0
votes
1 answer

flutter bloc BlocProvider.of(context) in the context of bottom sheet dialog

I have provided bloc in parent widget and trying to access that bloc instance in bottom sheet dialog. In bottom sheet dialog i have bloc builder which can not access the bloc instance. class HomeScreen extends StatelessWidget { @override Widget…
c__c
  • 1,574
  • 1
  • 19
  • 39
0
votes
1 answer

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

I'm developing a new Flutter Mobile app using the BLoC pattern . But I've got a problem and I don't find the solution yet. The first one is my home page (with the MultiBlocProvider) When I press on the FloatingActionButton. It push a new screen to…
Lapa Ny Aina Tanjona
  • 1,138
  • 1
  • 9
  • 19
0
votes
0 answers

Sharing state across Bloc

In my project I am using flutter_bloc library. I have many screens, for each screen I am using ScreenBloc and it works nice. However, I am finding myself duplicating States classes such as Init Loading, Error, Loaded…
Moti Bartov
  • 3,454
  • 33
  • 42
0
votes
1 answer

how to make a bloc builder build a widget when its not on screen?

Okay so Its kinda tough for me to explain but I will try my best. I am trying to make an app that follows Bloc state management. Right now, I have a bloc class that controls a bottom navigation bar and the widgets/fragments that it displays, one of…
Nayef Radwi
  • 1,305
  • 13
  • 25
0
votes
1 answer

flutter bloc: change color on each item when tap

I am trying to use flutter bloc so i create this bloc: class CategoriesBloc extends Bloc { CategoriesBloc() : super(CategoriesInitial()); List _catItems = [ CategoriesItem(id: 1, title:…
Cyrus the Great
  • 5,145
  • 5
  • 68
  • 149
0
votes
1 answer

What is the best way to using BLoC, one BLoC per screen or one BLoC per part of screen?

I'm currently developing the Flutter application using BLoC with flutter_bloc and I wonder what is the best way to manage the state using BLoC. In my situation, there're two main separate parts on the same screen. So, I end up created two BLoC for…
0
votes
1 answer

Passing a bloc to a widget as a paramater

How can I pass a bloc object to a widget as a parameter like this: I want to be able to pass either one bloc (TimerBloc) or another bloc (AnotherBloc) into this class and use that to return the BlocBuilder with that bloc. Like either this:…
Gerry
  • 1,159
  • 1
  • 14
  • 29