Closed IgorChicherin closed 4 years ago
Hi @IgorChicherin 👋 Thanks for opening an issue!
I'm guessing you're extending Equatable in your state classes and are not properly overriding the props
getter. Can you please share your SearchState
implementation? Thanks!
@felangel Yep, sure, here is states implementation.
abstract class SearchState extends Equatable {
const SearchState();
}
class InitialDataSearchState extends SearchState {
@override
List<Object> get props => ["InitialDataSearchBarState"];
}
class LoadingDataSearchState extends SearchState {
@override
List<Object> get props => ["LoadingDataSearchBarState"];
}
class LoadedDataSearchState extends SearchState {
final List<CampaignVenue> campaignVenues;
final LocationData currentLocation;
LoadedDataSearchState(this.campaignVenues, this.currentLocation);
@override
List<Object> get props => ["LoadedDataSearchBarState"];
}
class EmptyDataSearchState extends SearchState {
@override
List<Object> get props => ["EmptyDataSearchState"];
}
class ErrorLoadingSearchState extends SearchState {
final String errorMessage;
ErrorLoadingSearchState(this.errorMessage);
@override
List<Object> get props => ["ErrorLoadingSearchBarState"];
}
props
should return the properties for each class otherwise Equatable cannot do the equality comparison properly.
abstract class SearchState extends Equatable {
const SearchState();
@override
List<Object> get props => [];
}
class InitialDataSearchState extends SearchState {}
class LoadingDataSearchState extends SearchState {}
class LoadedDataSearchState extends SearchState {
final List<CampaignVenue> campaignVenues;
final LocationData currentLocation;
const LoadedDataSearchState(this.campaignVenues, this.currentLocation);
@override
List<Object> get props => [campaignVenues, currentLocation];
}
class EmptyDataSearchState extends SearchState {}
class ErrorLoadingSearchState extends SearchState {
final String errorMessage;
const ErrorLoadingSearchState(this.errorMessage);
@override
List<Object> get props => [errorMessage];
}
Also you need to ensure that CampaignVenue
and LocationData
extend Equatable
and override props
correctly.
Hope that helps 👍
@felangel oh, my bad, thanks alot for helping
Hello @felangel , i'm working on TDD clean architecture with bloc as state management, I have the same problem and tried to follow the instructions about the issue but it doesn't work I will put my bloc code just below.
`class ProductBloc extends Bloc<ProductEvent, ProductState> { final ProductRemoteDataSourceImpl productRemoteDataSourceImpl = ProductRemoteDataSourceImpl(); ProductBloc() : super(ProductInitial());
@override
Stream
bloc state code is here :
`
abstract class ProductState extends Equatable { ProductState(); }
class ProductInitial extends ProductState { @override List
class ProducStateLoading extends ProductState { @override List
class ProductStateLoaded extends ProductState {
final List
ProductStateLoaded({@required this.products}); @override List
class ProductStateLiked extends ProductState { final Product product;
ProductStateLiked({@required this.product}); @override List
`
Greetings, I have a mystical problem with rebuilding widget tree. BlocBuilder build only InitialState and don't handle yield a new states from bloc component.
flutter_bloc: ^2.0.0
Bloc implementation
Page implemenatation
Console Logs
flutter doctor