'Is there a difference between putting dispose on the first line and putting it on the last line?
What is the difference between the two code blocks?
First code block
TextEditingController textEditingController = TextEditingController();
@override
void dispose() {
super.dispose();
textEditingController.dispose();
}
second code block
TextEditingController textEditingController = TextEditingController();
@override
void dispose() {
textEditingController.dispose();
super.dispose();
}
Solution 1:[1]
super.dispose() should always be the last line in the overrided dispose function, because you should deactivate your specific widget before deactivating the super class widgets.
https://api.flutter.dev/flutter/widgets/State/dispose.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Abdallah Abdel Aziz |
