Flutter - Handling Life Cycle
dispose() is used to execute code when the screen is disposed. Equal to onDestroy() of Android.
Example:
@override
void dispose() {
anyController?.dispose();
timer.cancel();
super.dispose();
}
Add this in your Code