1,019 questions
Tooling
1
vote
5
replies
72
views
I'd like to try new status management in Flutter, what would be good?
Until now, I've only used RiverPod and Provider to do status management. I think they only use the same technology, so I want to proceed with the project using new status management, but I'm agonizing ...
Advice
0
votes
2
replies
92
views
What method should I use to move the view using BLOC in flutter?
I used RiverPod only every time to manage my condition, but I want to use BLOC this time, so I'm going to study it.
But I'm not sure how to move the view, so I'm posting a question!
I was wondering if ...
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 ...
0
votes
2
answers
206
views
How do you share cubit instance with go router
I want to share a single instance of a Cubit between both RouteA and RouteB.
Passing the Cubit via $extra results in a error: state.extra is an invalid type.
Using BlocProvider.value inside RouteB ...
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 ...
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. ...
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 ...
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,...
0
votes
2
answers
86
views
How to refresh a ListView after submitting data on a second screen?
I have a ListView in my first screen that displays a list of addresses. When the user navigates to the second screen to add or edit an address and then comes back to the first screen, I want the ...
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 ...
0
votes
1
answer
33
views
GalleryBloc not refreshing after granting permission
I'm working on a Flutter app where users need to grant photo access permission to load gallery images. I'm using Permission.photos for Android 33+ and Permission.storage for older versions. The ...
0
votes
2
answers
61
views
Syncing likes for photos between different screens in Flutter
Please help me choose the right way. I have an application with a list of photos, and you can like each photo. You can like it from the general list and on the screenshot of one photo.
The problem is ...
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
91
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/...
0
votes
0
answers
45
views
How to Create a Custom Async Wrapper Class for Managing States in Flutter Cubit?
I want to create a custom wrapper as AsyncValue<T> that can hold an asynchronous state (loading, data, error) and be used in a Cubit state class.
The goal is to avoid creating multiple Cubits ...
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
85
views
The argument type 'AuthState' can't be assigned to the parameter type 'AuthState Function()'
I am trying to test how is my widget reacting to BloC state changes.
This is how my test look like:
class MockAuthBloc extends Mock implements AuthBloc {}
void main() {
initHydratedStorage();
...
1
vote
2
answers
94
views
Textfield loses focus insed BlocBuilder
I have a textfield that is inside a BlocBuilder, so that the background color of the textfield changes depending on a parameter of the bloc (if the text entered in the textfield is empty or not). ...
0
votes
2
answers
64
views
ProviderNotFoundException when using multiple cubit in the MultiBlocProvider
I've been using cubit for my flutter project.
This is how my main.dart looks like,
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Set system preferences before running the app
...
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....
0
votes
0
answers
151
views
How to fix bloc listener emit the same state twice?
Hi i have this problem where my app failed to navigate correctly to a new page after getting success state, here what it should be:
First Page -> Second Page (listen when success) -> Last Page
...
1
vote
0
answers
59
views
Persisting a more complex object as bloc state in hydrated bloc?
So I decided on a BLoC pattern for my flutter app and so far it worked.
But then I also introduced the hydrated bloc plugin for persistence.
All I can find as examples in hydrated bloc is the same ...
0
votes
0
answers
236
views
Using Socket.io with Flutter stream and BLoC pattern
I'm trying to learn BLoC pattern using flutter_bloc package in flutter. I'm aslo using socket_io_client package to connect to a local Node.js server.
I have 3 problems:
The first, when the state ...
1
vote
1
answer
226
views
Does Bloc Rebuild (BlocBuilder) The Whole Widget Tree When New State emitted?
I encountered an issue when I wrapped my MaterialApp widget in a BlocBuilder. I expected the entire widget tree to rebuild whenever a new state was emitted. However, I noticed that some widgets didn’t ...
0
votes
3
answers
175
views
Flutter Cubit not emiting state with null values
I'm using Flutter bloc cubit and equatable to manage a simple form. in the birthday field, i check if it's a valid date and then send it to bloc and works fine. but if user then changes the date i ...
-1
votes
1
answer
73
views
How to handle multi states
i am building an app with flutter and firebase backed in which the user can go to a profile screen to edit it.
The profile has 2 parts, a view one, where the user can view all its data, verify its ...
0
votes
2
answers
97
views
Could not find the correct Provider<> above this BlocListener<, > Widget
I'm encountering the following error in my Flutter application:
Error: Could not find the correct Provider<SettingsBloc> above this BlocListener<SettingsBloc, SettingsState> Widget.
I'm ...
0
votes
2
answers
70
views
Bloc emit state issue
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:moms/features/chat/domain/entities/message_entity.dart';
import 'package:moms/features/chat/domain/usecases/send_message.dart';
import '...
-1
votes
1
answer
169
views
How to manage multiple states in a single BLoC without affecting the UI? [closed]
I'm developing a Flutter application using the BLoC pattern. I have a single UI page that interacts with a BLoC that handles 5 events and 10 states. My requirement is as follows:
When I fire an event ...
0
votes
1
answer
75
views
You used a `BuildContext` that is an ancestor of the provider you are trying to read
Error: Could not find the correct Provider above this RegisterScreen Widget
This happens because you used a BuildContext that does not include the provider
of your choice. There are a few common ...
1
vote
0
answers
57
views
Preventing Unnecessary Rebuilds in BlocBuilder with Form State Management
I have a state (formState) and multiple form-based input widgets like TextFormField, Dropdown, and others. Each widget has an onChange function and events, and the widgets are wrapped around a ...
0
votes
1
answer
47
views
Unable to get correct correct Provider from BlocProvider
I have a page which contains a button. When the user presses the button, a dialog box shows up which contains a bunch of textfields, etc. There is a toggle in that dialog box which changes the ...
1
vote
1
answer
79
views
How to maintain the rxdart broadcast stream listner when using bloc with stateless widget and navigating between screens?
I am learning flutter and flutter_bloc:8.1.6. I am developing a simple app where a user can add or edit their transactions and see a list of transactions when a new transaction is added or updated.
...
1
vote
1
answer
46
views
why absolute path gets BlocProvider related error in flutter?
when I use the following code snippet in flutter
import 'package:flutter/material.dart';
import 'package:flutter_app/features/note/presentation/screens/note_list.dart';
import 'package:flutter_app/...
1
vote
1
answer
106
views
Can I use BloC with only one state and not emitting new ones?
I needed to keep variables across few pages.
I created Cubit class for this, but in my thinking I didn't needed any state for this as my widgets doesn't depends on anything.
I just need to keep data ...
0
votes
1
answer
63
views
Bloc state is lost when navigating to another screen and come back in flutter
I'm using bloc with flutter to handle business logic and so on , code is working fine except when i navigation from HomeScreen to another screen , upon coming back to HomeScreen , all data from api is ...
1
vote
1
answer
706
views
Structuring BLoCs for Multiple API Calls in Flutter
I’m working on a Flutter application using the flutter_bloc package for state management. I have a page that requires fetching data from multiple API endpoints.
Scenario:
The page displays data from ...
0
votes
2
answers
83
views
Is there a way to pass a context from a page to a showDialog() in flutter?
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '...
0
votes
1
answer
103
views
Getit in flutter throwing unexpected error
I am getting this error
GetIt: The compiler could not infer the type. You have to provide a type and optionally a name. Did you accidentally do var sl=GetIt.instance(); instead of var sl=GetIt....
0
votes
1
answer
112
views
Flutter error - No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() [duplicate]
https://gist.github.com/ArpanMondalGITHUB/7012a4af48bed19d64eefc325fc23901
I am trying to sign up using Bloc and Firebase, but whenever I connect the BlocConsumer to the sign-up page form it gives me ...
0
votes
1
answer
45
views
How can I create a function to update the block data automatically in Flutter?
how are you, I am a novice developer and I am currently creating an app, in which I use Bloc Patter, I am obtaining data that is displayed on a main screen from Cloud Firestore and so far everything ...
0
votes
1
answer
560
views
Bloc provided to BlocProvider with get_it vs direct instantion?
MultiBlocProvider(
//option 1
[
BlocProvider(
create: (BuildContext context) => BlocA(),
),
// option 2
BlocProvider(
create: (BuildContext context) => getIt<BlocA>(),
)
],
child: ...
0
votes
2
answers
129
views
TypeError: type 'String' is not a subtype of type 'Map<String, dynamic>'
I am trying to get data from local storage and display it on the screen using flutter_bloc, but I am getting the error "type 'String' is not a subtype of type 'Map<String, dynamic>'". ...
1
vote
1
answer
215
views
Concurrency in Flutter Bloc: why is the state not propagating through multiple subsequent async functions?
I'm using Flutter with flutter_bloc, and I'm in front of the following scenario.
Scenario
I have a Cubit with two methods beings loadFoo and loadBar:
class UserCubit extends Cubit<UserState> {
...
0
votes
1
answer
32
views
StateFul Widget Not Rebuilding When Calling ValidateEvent with TextField onchange function flutter_bloc
I have a textfield with an onchnaged function which calls the validate service then returns the value to the widget.
i used print values to debug the code just to make sure everything was working fine....
0
votes
1
answer
116
views
How can I manage a model with 40+ editable field in flutter and BLoC
I'm currently developping an ERP application but I'm quite new to BLoC state management. I'm mostly a back-end developper, so maybe I'm doing things wrong.
I have a customer model that have 40+ ...
1
vote
2
answers
311
views
Is there better way to use multiple cubits on one screen
I initially created one Cubit to manage the state of my screen, but as it became too complex, I refactored it into four separate Cubits. Now, to make the screen function as intended, I had to ...
0
votes
1
answer
263
views
Flutter Bloc : Cannot add new events after calling close
I have a bloc registered in locator (Get_it). I am using the bloc in multiple UI components. But once i trigger the ui update event from some another screen it gives Cannot add new events after ...
0
votes
2
answers
691
views
Bloc Events not being executed sequentially
I have a piece of code where i need to call two bloc events sequentially the issue is that the first event is fired and api is called but the second is not being called , i tried to debug my code and ...