title: Infinite List with bloc (List length not changing in the presentation layer) in Flutter
body: <p>I am trying to load data from the api and i am using a bloc pattern for state management but when i call
  load more when scrolling the the presentation layer only change when the hasReachedMax parameter is true
  if it was false the ui still with the loading indicator</p>
  <p>here is the presentation layer</p>
  <pre><code>              Flexible(
                child: Container(
                  child: BlocConsumer&lt;AllProjectsBloc, AllProjectsState&gt;(
                    builder: (context, state) {
                      if (state is AllProjectsLoadingState) {
                        return Center(
                          child: CircularProgressIndicator(),
                        );
                      } **else if (state is AllProjectsLoadedState) {
                        return ListView.builder(
                          controller: _scrollController,
                          itemCount: state.hasReachedMax ? state.allProjectsData.length  : 
                          state.allProjectsData.length +1 ,
                          itemBuilder: (context, int i) {
                            return i &gt;= 5 ? BottomLoader() : UnitCard(
                              price: state.allProjectsData[i].price,
                              date: state.allProjectsData[i].title.en,
                              image: state.allProjectsData[i].image,
                              bathroom: state.allProjectsData[i].bathroom,
                              bedroom: state.allProjectsData[i].bedroom,
                              area: state.allProjectsData[i].area,**
  
                              function:(){
                                Navigator.push(context, MaterialPageRoute(builder: 
                               (context)=&gt;DetailedProperty()));
                              });
                          },
                        );
                      } else if (state is FilteredProjectsLoadedState) {
                        return Expanded(
                            child: ListView.builder(
                              itemCount: state.filteredProjectsData.length,
                              itemBuilder: (context, i) {
                                return UnitCard(
                                  price: 50,
                                  date: '20/5/2020',
                                  bedroom: 3,
                                  bathroom: 2,
                                  area: 120,
                                  image: 
                    
                    
               'https://www.propertyturkey.com/uploads/realestate/larg/buyukcekmece_villa_1_8.jpg',
                                  function:(){
                                    Navigator.push(context, MaterialPageRoute(builder: 
                       (context)=&gt;DetailedProperty()));
                                  } ,
                                );
                              },
                            ));
                      } else if (state is AllProjectsError) {
                        return ErrorView(
                            errorMessage: state.error.errorMessage,
                            retryAction: () {
                              BlocProvider.of&lt;AllProjectsBloc&gt;(context)
                                  .add(state.failedEvent);
                            });
                      }
                      return Container();
                    },
                   
        }
  </code></pre>
  <p>the bloc class</p>
  <pre><code>     class AllProjectsBloc extends Bloc&lt;AllProjectsEvents, AllProjectsState&gt; {
          List&lt;Data&gt; propertyList = List();
  
             AllProjectsBloc() : super(AllProjectsInitialState());
  
           bool _hasReachedMax(AllProjectsState state) =&gt;
              state is AllProjectsLoadedState &amp;&amp; state.hasReachedMax;
  
           @override
          Stream&lt;AllProjectsState&gt; mapEventToState(AllProjectsEvents event) async* {
             bool isUserConnected = await NetworkUtilities.isConnected();
              if (isUserConnected == false) {
                  yield AllProjectsError(
                failedEvent: event, error: Constants.CONNECTION_TIMEOUT);
                  return;
               }
             if (event is FetchAllProjectsData &amp;&amp; !_hasReachedMax(state)) {
                 yield* _handleFetchingAllProject(event);
                        }
  
                    if (event is FetchFilteredProjectsData) {
            yield* _handleFetchingFilteredProject(event);
              return;
            }
              }
  
           Stream&lt;AllProjectsState&gt; _handleFetchingAllProject(
         FetchAllProjectsData event) async* {
         if (state is AllProjectsInitialState) {
    yield AllProjectsLoadingState();
    ResponseViewModel&lt;List&lt;Data&gt;&gt; handleProjectsFetchingResponse =
        await Repository.getAllPropertiesData(1);
  
    propertyList = handleProjectsFetchingResponse.responseData;
    print(propertyList.length);
    if (handleProjectsFetchingResponse.isSuccess) {
      yield AllProjectsLoadedState(
        allProjectsData: propertyList,
        hasReachedMax: false,
      );
    }
  }
  if (state is AllProjectsLoadedState) {
    ResponseViewModel&lt;List&lt;Data&gt;&gt; handleProjectsFetchingMoreResponse =
        await Repository.getAllPropertiesData(2);
    List&lt;Data&gt; tempList = handleProjectsFetchingMoreResponse.responseData;
    propertyList.addAll(tempList);
  
    if (handleProjectsFetchingMoreResponse.isSuccess) {
      yield AllProjectsLoadedState(
          allProjectsData: propertyList, hasReachedMax: true);
      print(propertyList.length);
    }
  }
  return;
     }
  </code></pre>
  <p>state class</p>
  <pre><code>                     class AllProjectsLoadedState extends AllProjectsState {
  
                  final  List&lt;Data&gt;  allProjectsData;
                   final bool hasReachedMax ;
  
               AllProjectsLoadedState({this.allProjectsData , this.hasReachedMax}) : 
         super([allProjectsData , hasReachedMax]);
  
             AllProjectsLoadedState copyWith ({List&lt;Data&gt; allProjectsData , bool hasReachedMax }){
        return AllProjectsLoadedState(
          allProjectsData: allProjectsData ?? this.allProjectsData ,
          hasReachedMax:hasReachedMax ?? this.hasReachedMax
             );
      }
  
      }
  </code></pre>