onClose method
Called before onDelete method. onClose might be used to dispose resources used by the controller. Like closing events, or streams before the controller is destroyed. Or dispose objects that can potentially create some memory leaks, like TextEditingControllers, AnimationControllers. Might be useful as well to persist some data on disk.
Implementation
@override
void onClose() {
// Best-effort: release the wakelock so a non-permanent registration
// (e.g. a test tearing down) never leaves the screen forced awake.
unawaited(WakelockPlus.disable().catchError((_) {}));
super.onClose();
}