A Flutter screen can create an Azure SignalR connection and then forget who owns it.
The user pops the route. The app is backgrounded. The user logs out.
If nobody stops the connection, subscriptions leak. If a provider is disposed too early, the feed dies while the user is still on a child route. If you reconnect and treat the socket as a perfect log, you will miss events, because a new connection ID is not a replay.
This post is about that ownership problem. It stays on the Flutter client and explores Flutter lifecycle APIs, Riverpod disposal rules, and SignalR reconnection behavior.
A note about implementation: The Dart snippets are illustrative patterns, not production-tested code. They have not been compiled or analyzed. Microsoft does not ship an official Dart SignalR client, so confirm the API behavior against the community client you use.
The Problem
A HubConnection is not a widget state field you can ignore in dispose .…