PoojaB26/ParsingJSON-Flutter

API calls should not be in build() method

jirihradil opened this issue · 0 comments

Although it’s convenient, it’s not recommended to put an API call in a build() method.
Flutter calls the build() method every time it wants to change anything in the view, and this happens surprisingly often. If you leave the fetch call in your build() method, you’ll flood the API with unnecessary calls and slow down your app.

Source: https://flutter.dev/docs/cookbook/networking/fetch-data#why-is-fetchpost-called-in-initstate