skip to Main Content

I have seen in various files about init method under some classes, why we use this method and please also describe other useful methods if you know, Thanks

I have initialized this method but it didn’t work properly.

2

Answers


  1. The @initState method is called by Flutter when a widget is inserted into the tree. It’s important to note that the initState method is only called once, when the widget is inserted into the tree, and not every time the widget is updated. If you need to perform an operation every time the widget is updated, you can use the didUpdateWidget method instead.

    dispose, build, setState, build and much more method are interesting in Flutter, you can try to understand what each method do in this amazing "cookbook" in flutter documentation.
    https://docs.flutter.dev/cookbook

    Login or Signup to reply.
  2. To understand the methods and structure of flutter widgets, you need to understand the lifecycle of flutter screen or flutter application.

    So, basically flutter’s stateful widgets have really good methods which are

    1. CreateState()
    2. initState()
    3. didChangeDependencies()
    4. build()
    5. deactivate()
    6. dispose()

    You can learn more about this on medium

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search