-
In my case, when I call the API, it is often called twice with a difference of about 50ms. It's hard to tell if it's a problem with riverpod or something else, I was wondering if anyone has had similar cases with riverpod. If so, is there a workaround? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
No. |
Beta Was this translation helpful? Give feedback.
-
I can tell you for me its happened all the time. In my case it was ALWAYS because of rebuilds. Either a FutureBuilder would rebuild, or a riverpod I managed to solve them all by paying attention to minimizing rebuilds. Using riverpod When I couldn't solve the cause of the rebuild, then I resort to creating a variable for example
A bit hacky but it works when you can't find the reason otherwise |
Beta Was this translation helpful? Give feedback.
I can tell you for me its happened all the time.
In my case it was ALWAYS because of rebuilds. Either a FutureBuilder would rebuild, or a riverpod
watch
would cause a rebuild, or I would sneeze and I would get a rebuild.I managed to solve them all by paying attention to minimizing rebuilds.
Using riverpod
.select
was a god-send. Look into it, it can save you not of headaches.When I couldn't solve the cause of the rebuild, then I resort to creating a variable for example
bool didIcalltheAPIyet = false
and then once the API is called, I would switch that totrue
and block any further calls that way.