Questions tagged [bloc]
BLoC stands for Business Logic Component. The application implementation pattern of using BLoC is called BLoC pattern.
1,924
questions
0
votes
0
answers
23
views
emit state from listening to stream inside a bloc doesn't work
Im using StreamController to track the progress of uploading an image using Dio, so when i sink a value in my stream i trigger an event to emit new state to rebuild my widget, the problem is it does ...
0
votes
1
answer
21
views
Flutter BLoC 8.0.0. not emiting new state properly
I have created a BLoC (8.0.0) in Flutter that handles events in the UI. I have a ToggleButtons widget where the user toggles between three buttons and whichever one is currently selected, returns a ...
0
votes
2
answers
26
views
LateInitializationError hive using bloc
======== Exception caught by widgets library ======================================================= The following LateError was thrown building KeyedSubtree-[GlobalKey#74540]:
LateInitializationError:...
1
vote
0
answers
24
views
Stream doesn't recognize the change in Database
I am building note application which stores notes in database (I am using floor).
My stream is listening data in database and every change that is occurred it will automatically rebuild the screen.
My ...
1
vote
1
answer
22
views
HTTP GET Works in postman but failed in Flutter even with generated dart code from postman
i try to call api using generated dart code from postman. the link i put on flutter and postman is same link but only postman work.
import 'package:flutter/material.dart';
import 'dart:async' show ...
0
votes
2
answers
28
views
Flutter Bloc emit how to handle when the stream is done
await emit.onEach(
// This stream, how do you handle when this stream is done?
stream,
onData: (data){
}
);
Normally on Flutter Stream we have a callback onDone, but on emit onEach or forEach ...
2
votes
1
answer
39
views
What is the difference between a provider, a repository and a service?
I've been getting back to Flutter BLOC lately and I really struggle with some notions I've encountered and I can't find any reliable resources to make it more clear except a 13 years old SO post, a ...
0
votes
1
answer
21
views
Why "StateError (Bad State: add(LoginPasswordChange) was called without a registered event handler" error?
This is the code i copied from YouTube, and I had to change several lines, because flutter bloc had a new update, but the error still happened.
Widget _passwordField() {
return BlocBuilder<...
0
votes
0
answers
11
views
How to properly use EventTransformation with Bloc in dart
I'm trying to recreate the last example of the Bloc docummentation, in which there is a debouncer, by using a custom EventTransformer and applying it to the EventHandler of a Bloc.
This is my code:
...
0
votes
1
answer
36
views
what is the problem with this code because it is not listening the state changes
I am using flutter_bloc library and HydratedBloc to create Auth bloc. The problem here is that BlocListener is not listening to state changes,
so please let me know what I am missing in this code?
(...
2
votes
1
answer
37
views
Freezed+BLoc how to check the current state and the variables of an specific state from BLoc Listener
I'm trying to learn how to execute some code in a BLoC listener depending on the state and a code variable that's only present in the success state.
I would like to be able to tell if I'm on the ...
0
votes
1
answer
39
views
flutter bloc: how can i access to variables in bloc all over of tree?
I want to access one or more lists or variables throughout the tree of my program and also perform operations of adding, deleting, editing on that list, I solve this problem by using the provider ...
0
votes
0
answers
24
views
Why does my flutter BlocBuilder updates partially?
I have this piece of Flutter Bloc code.
child: BlocBuilder<SalesBloc, SalesState>(
builder: (context, state) {
var sales = state.allSales;
var sale = ...
0
votes
1
answer
51
views
How to conect entity(domain layer) and model(data layer) using BloC+Freezed
I'm trying to learn how to follow a clean feature-first architecture using Bloc and Freezed.
From what I've seen, I should have inside the Domain layer, an entity class declaring only its properties ...
0
votes
0
answers
30
views
Flutter: Do not scroll to top after insert new items before first
I am working on a MacOs App for browsing pictures using Flutter. One of the main challenges is scrolling over the directories.
I want to display a subset of my pictures. A header and all pictures per ...
2
votes
1
answer
37
views
Unable to update a prticular tile of ListView.builder using bloc
Scenario
I have a ListView.builder that creates 5 items. Each tile has a text and an icon. When the icon is tapped on it needs to toggle the font of the text between bold and normal as well as the ...
0
votes
0
answers
20
views
Page/BlocBuilder rebuilds on navigation return but there is no event in the logs
The situation is the following: I have 5 blocks on one page and each one returns a widget, however, when navigating to a new page (even if it is empty Scaffold () and I definitely don’t update any ...
1
vote
0
answers
22
views
Bloclistener listening multiple times in specific screen
Hey I'm using flutter_bloc in one case I'm consuming api when user press button if the response of api return success navigate to webview,and the button inside in the appbar which means in multiple ...
0
votes
0
answers
31
views
Flutter - Encountered a Error at an unrecoverable point. Failure was:
I'm quite a newbie into the flutter_bloc and I got stuck for a couple of weeks with this issue and I didn't figure out how to solve it.
The problem that I have is that The BLocBuilder from AddressView ...
-1
votes
2
answers
30
views
Unsupported operation: Cannot add to an unmodifiable list unsing Bloc
i am using bloc to add and remove from am list..
my bloc state is like this,
@freezed
class InterestActionState with _$InterestActionState {
factory InterestActionState({
required bool ...
-1
votes
1
answer
43
views
In Flutter, how to catch detail of NULL exception?
In my project, I use BLOC pattern with Stream. That stream watch Loading, Data and Error state then show to UI that states.
At first scenario, if in model file there is contain null value, UI only ...
0
votes
2
answers
46
views
How to create BLoC initial state based on dynamic JSON response
In my Flutter project I want to initialise BLoC (Provider/Cubit) once API responds with definition of shape of the state required for entire app.
Consider following shapes
shape-1
{
arr1: [],
arr2:...
0
votes
1
answer
45
views
Flutter: How to reuse same page but with different bloc
I have a page, which is used to display some multi-media in grid view.
In this page, I can upload photos/videos.
My app has a group data structure, and in a group, there is a list of posts.
Group can ...
0
votes
1
answer
68
views
Pass Data Between to Bloc Cubit
Hi everybody i have 2 cubit the first is get A List of Object and represent into a list View
the sconed cubit is get the details of the item when click it from the list and it take a id as parameter ...
0
votes
0
answers
27
views
What is causing the 'setState() called after dispose()' error in Flutter?
i have a footer widget :
Widget footer(BuildContext context) {
return Container(
child: GNav(
duration: const Duration(milliseconds: 400),
tabs: const [
GButton(
...
0
votes
1
answer
18
views
Flutter: How can I assign results from a BlocBuilder to a IconData?
I have this piece of Dart code used in a Flutter app. It's using the flutter_bloc library.
icon: BlocBuilder<SongsBloc, SongsState>(
builder: (context, state) {
var songSelected = ...
0
votes
1
answer
36
views
how pass data from parent to child widget using bloc
what is better ? pass state from parent to children or create each child a builder bloc?
(USING PACKAGE flutter_bloc)
BlocProvider(
create: (context) => ExampleBloc(),
child: BlocBuilder<...
0
votes
1
answer
43
views
Flutter Bloc State Change not updating & notifying the UI what was my mistake?
This was my code to change the state. If I uncomment Future.delayed everything works as expected. But I was trying to achieve without that.
void addExpense(
UpdateExpense event, Emitter<...
0
votes
0
answers
13
views
Flutter Bloc value of other variable changes without reason
This is my Bloc code. Here I was only changing value of allExpenses Amount not expensesMaster, but expensesMaster amount value changes what could be the reason.
loadExpensesData(
LoadExpensedata ...
1
vote
0
answers
25
views
Hi, I have a problem handling errors in Flutter with the Bloc library. the try catch block does not catch the error
I tried debugging on the function excursionss and the error is correctly propagated up to handleError method, but this error is not rethrown until the try catch of the Bloc:
Stream<List<...
0
votes
0
answers
44
views
Flutter BLoC: listen callback called multiple times
my blocConsumer listener calling muliple time i dont know why?
This is my auth cubit page
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../ApiManager/api_manager.dart';
import '...
0
votes
2
answers
73
views
Bloc listener not triggered
I have a login screen. When logo is clicked, I want display a loading on top of it. The loading widget I put in ContainerWithLoadingOverlay.
main.dart
class App extends StatelessWidget {
const App({...
1
vote
0
answers
29
views
Firebase authStateChanges Stream doesnt update
whenever a user creates an account, signs out or signs in into my app, the authStateChanges stream doesnt update unless I hot restart, and when i re-run the app it returns the correct widget.
Widget
...
0
votes
2
answers
40
views
Flutter, Bloc. What is the difference between operator== and const?
Why add operator== or some helper packages to states/events during comparison when you can just add const to the constructor?
abstract class PersonBase {
const PersonBase();
}
class Person extends ...
-1
votes
2
answers
37
views
Should I use StatefulWidget or a Cubit for this case? [closed]
I have to build a single page that consists of let's say a switch and a button. The user can continue to the next screen only if he has turned on the switch, then the user can press the button and go ...
1
vote
1
answer
39
views
flutter cubit to cubit communication not working
NOTE: POST UPDATED!
I have two cubits one of them is LoginCubit which is responsible for login actions and has 3 different states( LoginLoading, LoginSuccess, LoginFailure). The other cubit is ...
0
votes
1
answer
40
views
How to toggle open and close sub menu in each item of a list
I have a list of items. Each item has a button to show a sub-menu to do some action.
I want to show only a sub-menu and hide others. When I tap an IconButton it shows and hides a sub-menu and works ...
0
votes
1
answer
51
views
Dart bloc 8.1 and Stream
I have recently been converting the old code to the BLOC 8.1 version and I encountered the next problem. The application is multi -threaded and the mapEventToState method runs out stream and what is ...
0
votes
2
answers
58
views
Flutter Bloc Search Textfield reloads on every state change
I've developed a search screen using bloc patter to filter local list data. Here my problem is every-time I search filter the list the search box too get reloaded due to event change. Any solutions to ...
0
votes
0
answers
30
views
Flutter Bloc - State results to be closed if called from ValueNotifier's listener (Bad state: Cannot emit new states after calling close)
I have a splash screen that looks like this:
class SplashScreen extends StatefulWidget {
SplashScreen({super.key});
bool launched = false;
@override
State<SplashScreen> createState() =&...
0
votes
1
answer
46
views
The same repository for several BLoCs in flutter
Is it a good idea to use the same repository for several BLoCs?
0
votes
0
answers
33
views
Error: "Bad state: No element" when using BLoC_pattern
I need help.
I try to show a list of people in ListView.builder.
This is my code :
class TripMembersList extends StatelessWidget {
const TripMembersList({
Key? key,
required this.tripMembers,...
0
votes
1
answer
55
views
Why is my bloc throwing an exception condition?
All hello, I have a screen, when opened, a request flies to the server, it returns 400 error status to me, but why does it not get into an error state, but gets into an exception, why?
I should hit ...
0
votes
1
answer
24
views
How can I get parameter from Bloc without using Blocprovider/Bloccomsumer...?
I have defined a bloc named "AppBloc" that manage user login/logout activity of user:
class AppBloc extends Bloc<AppEvent, AppState> {
AppBloc()
: super(
const ...
1
vote
1
answer
25
views
hydrated cubit doesn't store state
In the following cubit, I tried to persist the state of the navigation of the application but when killing the app on the device and returning to the program it returns to the default state. How can I ...
0
votes
0
answers
39
views
Carousel Controller : 'positions.isNotEmpty': PageController.page cannot be accessed before a PageView is built with it
In my ScreenA I have a CarouselSlider package which I instance its controller in this way and I use it in that same screen.
final CarouselController _carouselController = CarouselController();
...
1
vote
1
answer
56
views
Flutter BloC state executed but the UI didn't change after the state changed
I am using the Bloc and Getx for state management and routing. I have solved the problem of the Bloc is nested with different child with the route which causing the Bloc cannot be found/read if I ...
0
votes
0
answers
25
views
Flutter BLOC: when receiving data synchronously over http, the widget content is not updated
Good afternoon!
The problem is the following: when receiving data synchronously over http, the widget content is not updated.
BLOC code:
class NotifyBloc extends Bloc<NotifyEvent, NotifyState> {
...
0
votes
0
answers
86
views
"How can I use Bloc to fetch and continuously display data from Firebase Realtime Database in Flutter?"
i have a food mobile application and i am trying to make the admin portal where i am submiting the meal based on the days and i can also delete each meal seperately by searching for the meal id and ...
0
votes
0
answers
46
views
How to prevent ListView.builder widget from rerendering when item is clicked
I am using a ListView builder widget inside a stateful widget class to display a categories menu. Inside this categories menu I created a method which is passed as parameter to CategoryItem class to ...