Flutter BLoC state is an amazing object. It’s store all the data related to that BLoC class or Cubit class.
If you use int, String, List or Map type object in your BLoC or Cubit class, You can find all of them from the state object.
state is State object. State class extends Object class, since in that case state could be any object.
And state object can be accessed anywhere as long as you use the below properties.
BlocProvider.of<BlocClass>(context)
BlocBuilder<BloCClass, StateClass>(builder){}
BlocConsumer<BlocClass, StateClass>(builder){}
Those above lines are used in UI screens, and you can access state object within those or from the object of those.
And in your Cubit or BLoC class, you can access the state object directly
Below are the cases that you can access
state.customObject, //customObject could be int, String, Map, List, Object
state as CustomStateClass, //stateful class
state is CustomStateClass, //stateful class
state[index] //list of objects stored in the state class
...state // to get all the states
If you have a class, and you wanna store it in a List and make it stateful, then wrap that class using BLoC or Cubit and that List of class becomes stateful and the state object would represent the List.
emit([…state]), you can also use the state object inside emit() function. In this case you are emitting a list of objects. But these are object are stateful.
Do remember state object always refers something from a class that you want to use for maintaining your variables as stateful.
Flutter BLoC App