My app has multiple pages, in each page I wrote a `didChangeDependencies

` function to fetch data from API (because I want to fetch data only when user entered that page).

Then I used `ChangeNotifierProvider` at the root of my widget tree. I found that there’s a loop:

didChangeDependencies() -> fetch data -> data changed -> notifyListeners() being called -> didChangeDependencies() being called again…

How do I overcome this issue and make sure the data is only fetched once only?

A JavaScript/Node/Flutter developer who love technical stuffs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store