dispose method
Disposes the controller and cleans up resources.
Automatically cancels the connectivity stream subscription if checkInternetConnectivity is enabled, preventing memory leaks.
Override this method in subclasses to perform custom cleanup.
Always call super.dispose() when overriding to ensure proper
resource cleanup.
Example:
@override
void dispose() {
myStreamController.close();
super.dispose(); // Must call super to cancel connectivity subscription
}
Implementation
@override
void dispose() {
if (checkInternetConnectivity) {
subscription?.cancel();
}
super.dispose();
}