Redeem Now
Read More
Read now

Lifecycle of Flutter App

Lifecycle of Flutter App, is the demonstration of how the app will change its State.

It helps in understanding the concept behind the smooth flow of our apps.

Flutter has majorly two types of widgets i.e. , Stateless and Stateful Widget.

Stateless Widget –  Stateless Widgets are those widgets which do not have to manage the State as they do not change dynamically at runtime.

Stateful Widget –  Stateful Widgets are those widgets which holds the State and the user interface being described can change dynamically at runtime.

So, as we are discussing about the LifeCycle of Flutter, we will be concentrating on ‘Stateful Widgets‘ as they have to manage the State.

FlowChart for Lifecycle of Flutter App

Stages in Lifecycle of Flutter App

createState()

This method is called when we create a new Stateful Widget.It is a mandatory method . It will return an instance of a State associated with it.

initState()

This is the method which is called when the Widget is created for the first time and it is called exactly once for each State object.

If we define or add some code in initState() method then this code will execute first even before the widgets are being built.

didChangeDependencies()

This method is called immediately after initState() method on the first time the widget is built.

build()

This method is the most important method as the rendering of all the widgets depends on it.

It is called every time when we need to render the UI Widgets on the screen.

didUpdateWidget()

This method is used when there is some change in the configuration by Parent widget.

It is basically called every time we hot reload the app for viewing the updates made to the widget.

setState()

The setState() method informs the framework that the internal state of this object has changed in a way that might impact the UI which causes the framework to schedule a build for this State of object.

It is an error to call this method after the framework calls dispose.

deactivate()

This method is called when the State is removed from the tree, but this method can be also be re-inserted into the tree in some other part.

dispose()

This method is basically the opposite of initState() method and is also very important.

It called when the object and its State needs to be removed from the Widget Tree permanently and will never build again.

Conclusion

In this blog, we have discussed about the lifecycle of flutter app.

I hope this blog will help you in understanding of Lifecycle in a better way.

Thank you for reading!!

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close