Questions tagged [cubit]
153 questions
3
votes
1 answer
Flutter Cubit: good way to get stored variable?
I'm using Flutter and Cubit for the first time, and I would like to know if this is a good way to retrieve a stored variable, in my cas the current loggued user.
After loggued in, the user can go to his profile page and see it/update it.
Login…

DimZ
- 297
- 4
- 18
2
votes
2 answers
Bad condition - Cubit
I'm trying to get to the RegistrationSendCode screen. But unfortunately I am getting a bad status error. Here is my provider and builder -
Provider -
class RegistrationSendCode extends StatelessWidget{
@override
Widget build(BuildContext…

Daniil
- 369
- 1
- 11
2
votes
1 answer
Flutter bloc Cubit Bad state: Cannot emit new states after calling close
I have an app that I build using Cubit
I have two pages A and B.every thing works fine on its own. I use a change status cubit on both pages but when I move to the second page and pop to return to the first page I see the error on the title.
I…

Ardeshir ojan
- 1,914
- 1
- 13
- 36
2
votes
2 answers
How can I use multiple cubits and emit states from both in the same screen?
I need to rebuild the body of the home screen when I add new task to get all the tasks including the last task added, I tried many solutions from many resources but I didn't find an solution.
here the home screen widget which build list view of all…

Mina Karam
- 21
- 5
2
votes
0 answers
flutter bloc:Is there a way to emit states with different data each time but all the data was fetched in the beginning?
I am using flutter_bloc library to manage the app's state.
I know how to use cubits and repositories to fetch data from API, but the thing is that I don't want to use all of the data that was fetched, in the first state emitted by the cubit.…

Mary
- 51
- 3
2
votes
1 answer
Proper use of cubit
I am still learning how to use cubits and blocs, and I am trying to use a cubit in my project, but I got a little bit confused about how to use it.
There is a screen that requires a phone number and I use the lib "intl_phone_number_input" to format,…

Gustavo F.
- 95
- 13
2
votes
2 answers
Update a widget from another one with Cubit Bloc
I have two widgets on a screen a Loading Widget and a button widget I want to change the state of the loading widget every time I tap on the button.
loading widget
class LoadingWidget extends StatelessWidget {
const LoadingWidget({
Key? key,
…

Ardeshir ojan
- 1,914
- 1
- 13
- 36
2
votes
1 answer
Why this BlocBuilder do not rebuild my list after second trigger?
I have cubit in which I download movies and pass it to the list:
class MovieSearchCubit extends Cubit {
MovieSearchRepoInterface movieSearchRepository;
List emptyList = [];
MovieSearchCubit({required…

Dawid Twin
- 27
- 7
2
votes
0 answers
How to Serialize object with XFile in Hydrated Bloc?
I'm using image_picker plugin to get images from gallery.
I save that image(XFile) in an object with bunch of properties. My State of HydratedBloc has list of that object. What is the best way to store that XFile for HydratedBloc?
What is the best…

Emil Mammadov
- 380
- 4
- 20
2
votes
2 answers
flutter bloc(cubit) state is not defined?
void emailChanged(String value) {
final email = Email.dirty(value);
emit(state.copyWith(
email: email,
status: Formz.validate([email, state.password]),
));
}
here it is my simple function. State is giving error I do not…

alperefesahin
- 604
- 6
- 22
2
votes
1 answer
Using BlocListener with Navigator PushNamed is causing ambiguity
I am facing issue while using bloc listeners for navigation
I have five screen for navigation and I am using BlocConsumer in every file. I am looking in flutter inspector for granular view. I am using blocListener for navigation. when I pushNamed…

Hammas Ali
- 454
- 1
- 4
- 13
2
votes
0 answers
Cubit - Flutter Error - "Looking up a deactivated widget's ancestor is unsafe"
I am trying to navigate to logIn Screen after logout. After logout, the screen is able to navigate but it throws an error:
Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer…

Aashish Jha
- 219
- 3
- 8
2
votes
2 answers
Flutter BLoC/Cubit STATE class best practices
I'm new to using Bloc and Cubit so I'm trying to figure out some best practices specifically with the State component. I have a simple Todos app where the Todos can be in multiple different states:
part of 'todos_cubit.dart';
abstract class…

rejy11
- 742
- 2
- 12
- 25
2
votes
0 answers
How to update a list in Flutter with Bloc/Cubit?
my UI consists of a table of objects Apples.
Every cell in the table:
has an ADD button, if the apple is NOT present for that cell
it shows the apple and has a DELETE button, if the apple is present
The main page of my application is calling the…

Federico Conte
- 93
- 7
2
votes
1 answer
Flutter cubit blocprovider couldn't find the correct provider
I am building a flutter app, in which the user can sign in with a google account. I'd like to manage this with cubit. I use Blocprovider to provide the cubit in the widget tree. The blocprovider is inside a futurebuilder in the runApp function.…

jdsflk
- 417
- 9
- 23