Skip to content

API calls should not be in build() method #5

@jirihradil

Description

@jirihradil

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions