2,211 questions
Best practices
1
vote
2
replies
52
views
Should I create separate cubits for adding/updating/deleting a model? Beginner to bloc
This is the first time I'm using bloc so it's a bit confusing for me.
I have a workout model, and a repository with methods to fetch all workouts, add new, update, or delete a workout. Initially I ...
Best practices
4
votes
5
replies
173
views
View model vs bloc in Flutter
As per MVVM architecture, I have to use a view model to separate data layer from UI. Can I instead use a Bloc for this purpose? What are the criteria to use one versus the other? Could you please ...
2
votes
1
answer
80
views
Unsuccessful implementation of DI with Injectable on the authentication
I am working on a Flutter application where I use Bloc as state management. I decided to try and implement Dependency Injection using the Injectable package and managed to implemented it on the ...
0
votes
1
answer
124
views
The block is not getting recognized error: The method 'read' isn't defined for the type 'BuildContext'
It's a cloned project. It's working fine in one PC, but facing issue in another.
Used Bloc for state management.
It's giving the error:
The method 'read' isn't defined for the type 'BuildContext'.
...
1
vote
0
answers
83
views
How do I model this structure with Bloc in my application?
Imagine I'm writing library management software. The library contains thousands of books, and each book can undergo multiple state changes (getting checked out, checked back in, reshelved, etc.) I've ...
0
votes
1
answer
81
views
Home screen twice gets loaded twice when authenticated
I am building a flutter web application and I'm using Bloc. I've created an 'authOrApp' route to check if the user is authenticated, but when I first run the web app it quickly loads the home screen ...
0
votes
0
answers
43
views
Multiple flutter BLoCs communication
I would like to chain two BLoCs.
My app supports multiple accounts. Therefore, I have a global BLoC that contains the currently selected account (GlobalAppCubit with GlobalAppState).
Then I have ...
0
votes
0
answers
101
views
How to share a bloc with its states among different routes using go_router
I am building my route navigation system using go_router. I git a point where I need to load a chat's messages and members to be used in the chat room and sub-routes. Some initial data, like chat ...
0
votes
1
answer
139
views
fetchNextPage is triggered immediately on widget build instead of on scroll when using infinite_scroll_pagination with BLoC
Description:
I'm using the infinite_scroll_pagination: ^5.1.0 package in combination with BLoC to implement infinite scrolling in my Flutter app. However, I’m encountering unexpected behavior related ...
1
vote
1
answer
109
views
type 'String' is not a subtype of type 'int' in type cast
iam using cubit for state managment and hive for local DB
the app is ecommerce the problem type 'String' is not a subtype of type 'int' in type cast occures when user enter the store page when the ...
0
votes
0
answers
40
views
How to update today date from shared Cubit without resetting other Cubits' states in Flutter?
I'm building a Flutter app where multiple pages rely on today's date to work correctly. Each of these pages uses its own Cubit, but I didn’t want to repeat the logic for checking if a new day has ...
1
vote
1
answer
88
views
Bloc throws an exception "emit was called after an event handler completed normally."
I am using bloc and socket.io in my flutter application to react to login states from the server.
Future<void> _setLoginListener(SetLoginListener event, Emitter<LoginState> emit)async{
...
0
votes
1
answer
52
views
Flutter bloc makes navigation slower
I am trying to navigate to QuestCartScreen after tapping on discover more quests button.I am using bloc for state management. But it is taking long time to navigate. The action occurs from homepage ...
2
votes
2
answers
98
views
state is not being emited properly
As the title implies emit isn't working properly so I created a basic app counter but a bit detailed so when the user click the increment button it supposed to trigger the state to be updated with the ...
9
votes
2
answers
3k
views
"Missing concrete implementation of 'getter _$CounterState.count'. Try implementing the missing method, or make the class " flutter bloc with freezed
I got an error in using flutter bloc and freezed page using for state management I couldn't find solution
"Missing concrete implementation of 'getter _$CounterState.count'.
Try implementing the ...
1
vote
1
answer
99
views
How to use flutter bloc/cubit for a page that contains multiple features?
I have this code for Authentication screen using GetX, I want to start using Bloc/Cubit, but I faced an issue about how to handle everything.
For example, in this page I have some fields that changes, ...
0
votes
1
answer
60
views
State gets called multiple times
State calling multiple times.
When I am clicking anyone google or facebook for login then my state gets called two times.
I am not understanding what is issue.
I have 2 pages 1. intro.dart and 2. ...
0
votes
1
answer
91
views
Handling flutter bloc states
I have question considering state management using Flutter bloc mainly cubit.
For example in my app I have todos states are
@immutable
sealed class TodosState {}
final class TodoInitial extends ...
2
votes
0
answers
58
views
Flutter BLoC - UI shows previous state after update
I'm using Flutter with BLoC to update user data. The problem is that after calling the update event, the UI doesn't reflect the updated data immediately. Instead, it shows the previous value on the ...
1
vote
1
answer
170
views
How to pass a bloc/cubit to a new screen with generated / named Routes?
I am trying to make a ListView of Widgets, each with it's own Cubit, when that widget is pressed the user should be redirected to a second screen where the informations from the Cubit of the pressed ...
0
votes
1
answer
65
views
No ScaffoldMessenger widget found inside Builder
main.dart:
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_template/bloc/...
0
votes
0
answers
44
views
When updating the ThemeMode in a Flutter app, the build method of the Homepage is called multiple times
Here is my code. Although I use BLoC for state management (the same applies to GetX), when I press the button (Change ThemeMode), I find that the console prints multiple times:
flutter: >>>&...
0
votes
0
answers
77
views
Flutter bloc doesnt listen to state change
I am changing the state in my profile bloc in response to a onTap. Then i want my bloclistener to listen to the state change and use my navigation to go to a new screen.
I've already done this in ...
2
votes
1
answer
135
views
flutter_bloc persistent errors
I have been working on an a Flutter app using Flutter_bloc, testing it multiple times per day no problem,
tonight and after performing 'flutter pub upgrade' I got this errors; no matter what I do, the ...
0
votes
1
answer
93
views
How to trigger another Bloc when one Bloc state changes?
I'm working with Flutter Bloc for state management. I have a ThemeBloc that toggles between light and dark modes, and I want to trigger AppBloc to perform an action whenever the theme changes. However,...
1
vote
1
answer
54
views
mocking events in flutter_bloc, to isolate event testing from calling other events
I have a bloc event, and I'm writing test for it, my event have one case that will add another event, that I don't want to include in test because I'm focusing on one event, so I have tried multiple ...
1
vote
1
answer
130
views
Does Flutter Bloc handle multiple rapid event emissions correctly?
I'm working with Flutter Bloc and noticed that when I dispatch the same event multiple times in quick succession, Bloc emits multiple Loading states before transitioning to Success. This behavior ...
0
votes
2
answers
73
views
Flutter Bloc - How to show an "refreshing" overlay
I have a widget/screen that shows some content. At the bottom of the page is a "Refresh" button.
What is the best way to show a "Refreshing" overlay on tap of the button without ...
0
votes
1
answer
73
views
Bloc plugin generates empty files often (Flutter)
Maybe anyone knows why the Bloc plugin in the Android Studio generates the empty files when you are creating the new templates?
I tried to invalidate caches, restart IDE, reinstall the bloc plugin.
...
0
votes
1
answer
90
views
How can I pass bloc to another screen in flutter [duplicate]
in main.dart
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: ...
-1
votes
1
answer
82
views
DartError: LateInitializationError: Field '__storage' has not been initialized when updating from hydrated_bloc 9 to 10 and flutter_bloc 8 to 9
i follow the migration guide https://bloclibrary.dev/migration/ but i get this error
DartError: LateInitializationError: Field '__storage' has not been initialized.
dart-sdk/lib/_internal/...
2
votes
1
answer
135
views
How to make Material Autocomplete work with Bloc?
I'm trying to combine Material Autocomplete widget with Bloc pattern for Google Place Autocomplete function.
My code as below:
BlocBuilder<MyBloc, MyState>(
builder: (context, state) {
...
1
vote
1
answer
81
views
How do I access a Bloc declared in MultiBlocProvider from a page accessed via a route?
I'm relatively new to Flutter and Bloc and am confused on how to use the MultiBlocProvider correctly. I have a list page and a create page, to create an item for the list.
I've tried:
putting the ...
1
vote
1
answer
64
views
Executing Bloc Events Synchronously Across Different Blocs
I need to execute multiple events from different Blocs synchronously, ensuring that each event completes before the next one starts. Here's the current code:
context.read<PaymentBloc>().add(...
0
votes
1
answer
59
views
Screen not reacting to Bloc event after navigating
So I currently have 2 screens, one screen has a button and when the user presses the button, second screen gets displayed. Nothing too complicated...
The second screen should react to what the Bloc ...
0
votes
1
answer
88
views
Using HydratedBloc -- LateInitilizationError Field '__storage@30190796' has not been initialized
I am trying to learn Flutter and Bloc/ HydratedBloc. I can't seem to get past an exception I keep getting when trying to save a value to local storage. I have tried creating this new simpler project, ...
0
votes
1
answer
243
views
HydratedBloc expects a type HydratedStorageDirectory but getApplicationDocumentsDirectory returns a type of Directory
I am new to Flutter and currently trying to learn Bloc and HydratedBloc. I am trying to initialize the storage using getApplicationDocumentDirectory() and use it for the storageDirectory parameter in ...
1
vote
0
answers
86
views
Problem with the state of the category selection buttons
I have containers with various specialties. They are taken from the API. I have a problem with updating the state of the buttons. I will give an example in the video of how it should work and how it ...
0
votes
0
answers
147
views
Widgets don't rebuild using go_router and async redirect
I've been trying to implement navigation from login page to home page based on authentication status from firebase.
Untill now Ive had this simply done with bloc listener (therefore I know the whole ...
1
vote
0
answers
21
views
Unable to trigger listeners in bloc event integration test
I'm doing an integration test, where I want to trigger an event change after a submit button. below is my setup for the test as well as the actual test, I've tried multiple ways and positions to set ...
0
votes
1
answer
55
views
Flutter Bloc Listener Not Detecting New States and Failing to Update Map Markers
I’m using flutter_bloc in a Flutter application to manage the state of a GoogleMap. The BlocListener is responsible for reacting to state changes emitted by a Cubit, such as new student locations or ...
0
votes
1
answer
50
views
Dependent multiple dropdown issues using bloc in Flutter
I have a screen where there are 2 dropdown widgets. When I select first dropdown and want to show a loading widget then I am getting error.
My problems are:
When I select territory then app is ...
0
votes
1
answer
117
views
Could not find the correct Provider<CubitSubject> above this BlocBuilder widget in Flutter
I'm facing an issue with accessing my CubitSubject provider in a specific screen. I have a MultiBlocProvider in the root of my app, and I'm trying to access the CubitSubject in the SubjectsView screen....
3
votes
1
answer
128
views
How do I access multiple BloCs from a single component in Flutter Flame?
I am building a Flutter Flame game and am trying to have a single action add events to two different blocs. For example, when the character picks up an item I want it to go into an InventoryBloc and ...
1
vote
0
answers
28
views
multiple Instances of screen injected Flutter Bloc with OnGenerateRoute
I am working on a Flutter app using the Bloc pattern for state management, and I’m encountering an issue where multiple routes are being pushed onto the navigation stack despite having a single ...
2
votes
0
answers
73
views
Why doesn't the Autocomplete widget update the suggestions when rebuilt?
I'm trying to build a search bar where the user can look up for a place, and select a suggestion corresponding on what caracters they wrote.
I'm using BLOC, and an API to fetch the suggestions from ...
1
vote
1
answer
58
views
Flutter blocs with API requests
I am getting response data from an api while passing in a response body. I have built my state, event, repository of my request but upon calling the user details event in my home page where I want to ...
1
vote
1
answer
88
views
Vscode shows explorer files red after running build runner
I'm using the build runner package in my Flutter project. But whenever I ran the following command
dart run build_runner build
Some of the bloc state files turn red in the vscode file explorer. I ...
1
vote
0
answers
47
views
Optimization of videos from Flutter App Api Call
I list videos from api on my page in Flutter.I used the PreloadPageView 'preload_page_view' package to list the videos.The videos are in mp4 format. Video sizes average between 100-200 mb. I make the ...
1
vote
1
answer
94
views
Flutter bloc event is not getting called on initial screen load
I just started with flutter bloc and I want to call an event on screen initial load. I have the following code but the event AuthEventCheck is not getting called.
void main() {
runApp(const MainApp()...