Home > Back-end >  Are Statefull widget deleted and replaced when being rebuild using setState()?
Are Statefull widget deleted and replaced when being rebuild using setState()?

Time:02-16

As per my inforamtion,

flutter has a widget tree and an element tree. For every stateful widget in the widget tree an element in the element tree is created with state object attached to it, that is pointing at the widget and which rebuilds the widget when we call setState(), by destroying it and replacing with a new widget.

If the widget is destroyed, then where is all the widget configuration held until new widget is replaced instead of the old one?

CodePudding user response:

there are 3 trees : Widget Tree, Element Tree and Render Object Tree.

watch this:

How Flutter renders Widgets

CodePudding user response:

the widget is not really destroyed if you call setState

only on the screen the widgets was destroyed if you call setState

  • Related