Bloc: My RefreshIndicator keeps rolling.

Created on 10 Sep 2019  路  6Comments  路  Source: felangel/bloc

Hi @felangel

I am having some issues with my page RefreshIndicator (I am using bloc), as the indicator keeps rolling. It actually work well sometimes. For example, like after I scroll down and new contents are loaded.

I am thinking that the BlocListener is not called every time my Refresh event is triggered.

Here is the link to the page with the list view and RefreshIndicator: https://github.com/geegog/todo_flutter/blob/master/lib/task/pages/all_todo.dart

Here is the link to the bloc: https://github.com/geegog/todo_flutter/blob/master/lib/task/bloc/alltodo/todo_bloc.dart

Please, can you point me in the right direction?

Thank you.

question

Most helpful comment

@felangel thank you for your response.

It works now!!! 馃憤

All 6 comments

is TodoLoaded extending from Equatable ?

@bigworld12

Yes it does.

Hi @geegog 馃憢
Thanks for opening an issue!

It looks like it's because Todo does not extend Equatable so the bloc thinks that no state change has occurred.

Hi @felangel

Thanks for your response.

My Todo class extends Equatable.

Here is a link to my Todo class: https://github.com/geegog/todo_flutter/blob/master/lib/task/domain/model/todo.dart

@geegog no problem! I took a closer look and I believe it's because when you refresh, if the refreshed data comes back and is the same as the previous data then the bloc will think that no state change has occurred. In this case you should either add a unique identifier to the state so that every refresh state is different or you should just not extend Equatable for the TodosLoaded state. I would recommend adding a unique identifier like a timestamp to your TodosLoaded state 馃憤

Hope that helps!

@felangel thank you for your response.

It works now!!! 馃憤

Was this page helpful?
0 / 5 - 0 ratings