How to use bloc with show Dialog flutter
currently, I have an IconButton in the appbar of ListScreen. But when I click on it, it show up an error that do not recognize bloc in widget tree ? what can i do.
how to add item into a list in another state, when call api success flutter bloc
My idea is the first time I add load a list from api and I get GateInLoaded state with some list in it,
Then I can call api Add to add a new item in that list, if the response has no error
I’m trying to manage state using Bloc. but i keep getting this error “This expression has a type of ‘void’ so its value can’t be used.”
class FavouriteBloc extends Bloc<FavouriteEvent, FavouriteState> { FavouriteBloc() : super(FavouriteInitial()) { on<AddToFavorites>((event, emit) { List<HostelModel> hostelList = []; emit(FavouriteUpdated(hostelList.add(event.hostel))); }); on<RemoveFromFavorites>((event, emit) {}); } } sealed class FavouriteEvent {} class AddToFavorites extends FavouriteEvent { final HostelModel hostel; AddToFavorites({required this.hostel}); } class RemoveFromFavorites extends FavouriteEvent { final HostelModel hostel; RemoveFromFavorites({required this.hostel}); } sealed class FavouriteState {} final […]
In flutter BLoC, how to optimize the creation of repeated, multiple dart files?
I am working on a flutter project. I have 5 basic components where I have a list of items to display, add item screen and delete item screen. So in all of the modules I am gonna have same states & events. I want to know whether it is critical to maintain a dedicated state.dart file & event.dart file for each of the components ?
Unable to set text in Flutter
I am using Bloc pattern and I am getting successful response/data when printed but when I am setting the response on the Text widget its giving me error.
My Hydrate Bloc is not persisting the state after restart or closing the app
I am trying change and update the state using radio button. State are changing successfully when I am clicking the radio button. But after hot reload or closing the app it can’t hold the state. I am using the hydrate bloc
Flutter Bloc – how to handle form related state
I’m new to Flutter Bloc, I’m handling customer related bloc where there can be following states CustomerLoaded, CustomerLoading, CustomerAddLoader and CustomerInvalidForm