Questions tagged [cubit]
153 questions
1
vote
1 answer
Flutter - Error in hot reload using lazy internationalization
I'm building an application that uses lazy internationalization, this way there will be no translation files in the application and all translations will be fetched from the internet when a new page is opened. For that I am using a localization…

Gustavo F.
- 95
- 13
1
vote
1 answer
Does Cubit only works with Stateless Widgets?
I am trying to apply this state management but i cannot implement it. If I use stateless widget, i can easily implement it but stateful it is complicated and i cannot achieve it. Where to implement cubits? Here is my code part =>
class…

theredboy
- 92
- 10
1
vote
1 answer
Check if a cubit is in the context
is there a way to check if a cubit/bloc is available in the current context.
I have a widget which is used in different pages/widgets, an some of the pages are using a cubit, but not all.
I need the state of the cubit, but only if a cubit is…

A.K.
- 568
- 5
- 17
1
vote
0 answers
Flutter Cubit state gets emitted twice
In Flutter, when I call the cubit method below, the state is getting emitted twice.
Can someone help me find what's wrong with my code?
Cubit class:
class AlertCubit extends Cubit {
AlertCubit() : super(AlertInitial());
void…

fforflutter
- 64
- 5
1
vote
1 answer
Pages not maintaing state while scrolling
I created this multiple pages which has different widgets inside it like TextFormField, DropDown, checkBox etc. I created a widget that selects pages on basis of question type fetch from api.
This question selector widget is called inside…

Aabhash Rai
- 147
- 1
- 9
1
vote
0 answers
Authentication with Flutter Bloc/Cubit
How do I set current user using hydrated storage instead of cachedClient
Like its done in bloc docs for firebase login?
They wrote in user repository:
Stream get user {
return _firebaseAuth.authStateChanges().map((firebaseUser) {
…

Ksenia Alexeeva
- 31
- 2
1
vote
1 answer
How to cancel cubit old function call?
I am trying to use cubit in my flutter project but i am facing this problem i am trying to call a function its function with future return type so its need time to be done but at the same time i got a notify so i need to call another function in…

majd alshalabi
- 41
- 5
1
vote
0 answers
Flutter Bloc/Cubit with multiple properties in one Cubit class
I'm trying to use Bloc package for my state management in my Flutter app. I have situation where I have two list within the same screen, and I am confused should I use two cubits for each list or I can make something like in code bellow where I used…

Net Korona
- 11
- 2
1
vote
0 answers
How to handle validation and navigation situation on Cubit right way?
In my application I have AddServerScreen Page which allows me to add Servers to Cubit. The server object has two properties, alias and address. If the alias of the server to be added matches one of the servers kept in Cubit, I do not add the server…

Emil Mammadov
- 380
- 4
- 20
1
vote
1 answer
I have a problem with Null Safety an the problem is 'Null check operator used on a null value'
It happened when getting some data from firebase and decoding them using model,
and here is the method:
UserModel? userModel;
void getUser() {
emit(GetUserLoadingsState());
FirebaseFirestore.instance.collection('users').doc(uId).get().then((value)…

Alaa Elsweedy
- 23
- 7
1
vote
3 answers
can't use bloc observer after bloc update
I have a problem with the last update of bloc 8.0.1 I can't use the bloc observer and I used the BlocOverrides and still not working and here is my code
my main class code
BlocObserver
import 'package:bloc/bloc.dart';
class MyBlocObserver extends…

Mahmoud Mashaal
- 21
- 1
- 2
1
vote
1 answer
How can a Flutter Cubit emit multiple state changes
I have a Cubit that retrieves json data from an API. It processes the data and based on the processing, will need to change the state of multiple widgets.
Essentially, using some if statements, the state changes will need to be emitted if the data…

MBU
- 401
- 5
- 16
1
vote
1 answer
How to integrate data retrieved from an API via Timer.periodic into Flutter Cubit project
I am working on a Flutter Bloc/Cubit based application in which I will need to have a Timer.periodic running that will retrieve data from an API at a certain repeating duration and then update the UI if new data is retrieved.
I'm confused as to the…

MBU
- 401
- 5
- 16
1
vote
0 answers
UI only Updating once when using Cubit while an updated list is emitted
I am adding and removing items to a list that is used to render a data table. But state Is only changing when the first element is added. but it won't rerender for the next clicks. but if i emit a state with [] and then emit the list it render…

Vivek Mohan
- 11
- 1
1
vote
1 answer
BlocListener not being executed after Cubit function call
So, I have a cubit with a function that POSTs some data. I have three states, DataLoading, DataError and DataLoaded for my cubit.
When the user taps on a button, I call the function in the cubit. After that, I have a BlocListener to wait until the…

IncorrectMouse
- 179
- 1
- 9