Questions tagged [flutter-cubit]

96 questions
8
votes
1 answer

What is the difference between between context.watch and context.read in flutter_bloc?

I just learn about a cubit in a flutter. I learn in the tutorial video, so in that video, the mentor made a login page that contains an email and password text field and one login button. In that video, the mentor still uses the old version of…
6
votes
1 answer

Can i call cubit from another cubit?

i'm working on an application that uses cubits, to manage the state. Very often when i need to make an api request i need to get my current localization (handle possible exceptions) and then send it to backend. So i guess i should use cubit for the…
6
votes
1 answer

How to use BlocBuilder to refresh a Dialog in Flutter

I have a dialog and I wrap it in a blocbuilder to update it according to the type of state but the dialog just is built First time and after state has changed it doesn't rebuild. showDialog( context: context, builder: (_) { …
Parisa Baastani
  • 1,713
  • 14
  • 31
4
votes
0 answers

How to make a second API call based on the first response in flutter with cubit?

There is a problem with the first call I have to get the value list of values from the first API to make a second API call. how do update the data to UI. I have two listviews one is for loading from the first API and the second listview is for the…
kumar
  • 111
  • 12
3
votes
1 answer

Toggle theme mode using bloc in flutter

I'm new to flutter, I'm building an app using bloc for state management. I'm trying to toggle theme mode using IconButton on the appBar but the theme won't change when I press the button. how can I fix that ? I'm creating this app by watching a…
3
votes
1 answer

Flutter - cubit - changing boolean value inside cubit

I would like to change bool values from the cubit, but I can't figure out how to do it. What I want to achieve is, for instance: if (boolean value stored in cubit is true) "show widget A" : "show widget B" My code: class ChangeBoolCubit extends…
mmcib
  • 131
  • 1
  • 10
2
votes
1 answer

How can I change bool true false with cubit?

I want to show an icon if bool editI == true and don't show it if editI == false. But I can't change the value of editI in cubit.dart and pass to page.dart I have this cubit class LayoutCubit extends Cubit { LayoutCubit() :…
Mus
  • 67
  • 1
  • 13
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

Flutter : Multiple Cubits Example

I'm using Cubits for state management in my Flutter app. It is my favourite state-management approach so far. However, I now want to get a little more complex, and have multiple cubits, controlling different bits of state each (eg. one is for…
Turkey
  • 346
  • 4
  • 16
2
votes
2 answers

Flutter Bloc - is there a way to provide different instances of a bloc in a screen

I have a cubit named FoodCubit which has two functions: -getAllFoods() -getFilteredFoods(category) And I have a screen like below As you can see top part of the screen is a blocbuilder returning states emitted by my first function which is called…
R3HP
  • 470
  • 4
  • 13
2
votes
1 answer

Flutter TextFormField trigger onFieldSubmitted when focus is lost

I am using Cubit to develop my platform. I have a custom form to edit a record. All the TextFormFields receive an initial value. My problem is that when the user finishes editing each TextFormField, I need to update the state of my cubit. I can't…
1
vote
2 answers

BlocBuilder not necessary

I am continuing a Flutter project of mine after quite some time and I no longer understand why a very basic pattern works. As far as I remember and what I understand from the documentation, I need a BlocBuilder to update a screen upon a state…
w461
  • 2,168
  • 4
  • 14
  • 40
1
vote
2 answers

type Context is not a subtype of type BuildContext

I have created a Flutter Cubit class that has a method that create an object of itself, the problem is when I try to create a variable of this class with this method I get a type error, so what is the solution? class AppCubit extends…
John Samir
  • 11
  • 3
1
vote
0 answers

Flutter Navigation 2.0 with bloc and cubit pop and back button not working

I am implementing flutter navigation 2.0 for mobile with BLoC and cubit. Navigating from one screen to the other declaratively is working fine. The issue is when I pop using the back arrow or tap Android back button. The back arrow loops back to…
1
2 3 4 5 6 7