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

Migrating my bloc app to null safety. error: 'AssignmentBloc' doesn't conform to the bound 'BlocBase' of the type parameter 'B'

I'm migrating my flutter app to null-safety and I get this error on my BlocProvider and BlocBuilder. 'AssignmentBloc' doesn't conform to the bound 'BlocBase' of the type parameter 'B'. Try using a type that is or is a subclass of…
0
votes
1 answer

Using a list of blocs/cubits

I'm new to bloc and I failed to find an example of code for my case. In my app I have such entity as a Player and I want to manage state for both each individual Player (changing his name and score) and a list of Players (adding/removing players). I…
0
votes
2 answers

Flutter Trigger bloc event again

On my first screen, I fill out the form and then click the next button it added SubmitDataEvent() to the bloc. Then, the BolcListner listing and when it comes to SuccessSate it navigate to the next screen. on the second screen, when I click the…
Akila Ishan
  • 147
  • 2
  • 12
0
votes
1 answer

Bloc Dart : When I add async* to my on function in my_bloc_bloc.dart file , add an event with flutter_bloc does not make anything

Here is my code when I add async* (Hello World! is not printed): import 'package:alltoo_mobile/authenticate/bloc/authenticate_bloc.dart'; import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; part 'login_event.dart'; part…
Dev Lulu
  • 237
  • 2
  • 9
0
votes
0 answers

Pagination page number automatically increments after navigation in Flutter

I'm calling an api by using http package and the state management i am using is flutter_bloc library. In this api there is a pagination where if the user scroll at bottom the page number increases. I successfully implemented this pagination by using…
Mohammed Nabil
  • 662
  • 1
  • 8
  • 36
0
votes
1 answer

Flutter Bloc : There is no ancestor of my bloc in the context founded while I have it well provided with a BlocProvider.value

Here is where I create my Bloc (main file): if (state is AuthenticationAuthenticated) { return BlocProvider( create: (context) => NavigateHomeScreenBloc(state.user!.uid) ..add(NavigateToProjects()), …
Dev Lulu
  • 237
  • 2
  • 9
0
votes
1 answer

Dart generic programming

I'm trying to implement a BLOC pattern for the Flutter project, my code is plentifully reusable, so I decide to use generic programming to implement it. First I defined the event classes: import 'package:flutter_bloc/flutter_bloc.dart'; abstract…
Ayad Salim
  • 88
  • 7
0
votes
1 answer

How can I write "Event1 'or' Event2" inside on method from flutter_bloc?

That's my code for PostsBloc: class PostsBloc extends Bloc { final _dataService = DataService(); // Constructor PostsBloc() : super(LoadingPostsState()) { on((event, emit) async { …
rebix
  • 78
  • 5
0
votes
1 answer

With Flutter blocs, how do I use two events with the same callback?

I'm using the library flutter_bloc and I have two different events -- one that will accept arguments while the other will not. class LoginSubmitted extends LoginEvent { const LoginSubmitted(); } class LoginFromSignup extends LoginEvent { const…
nyphur
  • 2,404
  • 2
  • 24
  • 48
0
votes
1 answer

Flutter BlocBuillder not receiving state updates

bloc newbie here. As per title, i have a BlocBuilder which is a child of a BlocProvider. This BlocBuilder is not receiving updates after the very first one and i can't understand why after many hours. Can someone explain that to me? The goal is to…
Max90
  • 79
  • 6
0
votes
1 answer

how to use flutter bloc

If I have many actions in my app like ( get popular movies, get trending movies , get new movies , get top rated movies) each one represent single screen with it's own state should I use one bloc for all actions or have one bloc per action ? all…
goo add01
  • 1
  • 1
0
votes
1 answer

Flutter BLoC is not updating the state or notifying the changes in the screen or widget

I am building a mobile application using Flutter. I am using BLoC for state management. I am using this library, https://pub.dev/packages/flutter_bloc. I app is emitting the event to the Bloc class. But the state is not updated in the screen or…
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
0
votes
1 answer

cubit state return always a null value

i am learning flutter-bloc with freezed, i am trying to retrieve a data from sqflite. i have a achieved that without bloc pattern, it worked fine. but when i use bloc to do so the return value is always null!. This Button when is clicked it is…
0
votes
1 answer

Another exception was thrown: Error: Could not find the correct Provider above this BlocSelector Widget

i am using cubit with freezd. i have an input text form field inside a bottom sheet, all thing is perfect, but once i clicked the input form field and typing any letter this exception occurs. Another exception was thrown: Error: Could not find the…
0
votes
1 answer

BlocSelector usage

In bloc 7.2.0, What is the usage of BlocSelector ? I need a practical example for this widget. BlocSelector( selector: (state) { // return selected state based on the provided state. }, builder: (context,…