mohanedy/nile-gift

An infinity rebuild issue

Closed this issue · 1 comments

Hi,

I really like this app.
Especially, the way you handle SliverAppBar in character_screen.
But, I also found a bug about rebuilding on this page.

Reproduce:
if you put print(constraints.biggest.height) in character_screen.dart#L146, you might see the info be printed infinity in your debug terminal.
https://github.com/Mohanedy98/Gift-of-The-Nile/blob/b027b39f2665c76921c14e5abd133ae2c4d835aa/lib/screens/character_screen.dart#L146

Do you have any idea to solve this issue? I really really want to apply for your approach in my app.

Thanks.

Thanks for letting me know about this issue the problem was that the LayoutBuilder widget keeps changing barOffset stream value even the value is not changed because, _bloc.changeBarOffset(constraints.biggest.height); was placed directly in the build method without any conditions which cause the infinity rebuild issue I have fixed this issue in the last commit and the solution is to add this condition.

if (constraints.biggest.height != offsetSnapshot.data) {
_bloc.changeBarOffset(constraints.biggest.height);
}

Thanks.