According to the documentation
dispose method
Called when this object is removed from the tree permanently.
Regarding a page, the dispose method is called when the page is removed from the navigation stack. Here is a good explanation of Navigation
.
When your widget (page) extends StatefulWidget
, it's not mandatory but you can override the dispose
method to execute additional instructions depending on your need. The method is called automatically when the page is being removed from navigation tree. Override the method as following
@override
void dispose() {
// your desired instructions here
super.dispose(); // This will free the memory space allocated to the page
}
Nonetheless, the method void pagedispose()
cannot be overridden as it ain't a known method of StatefulWidget
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…