Skip to content

Commit

Permalink
fix: Socket state
Browse files Browse the repository at this point in the history
  • Loading branch information
taorepoara committed Jan 12, 2024
1 parent daac25b commit 519ff7d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ class _SocketManagerState extends State<SocketManager> {

socket.onOpen(() {
print("Socket opened");
setState(() {
connected = true;
});
if (mounted) {
setState(() {
connected = true;
});
}
});
socket.onClose((_) {
print("Socket closed");
setState(() {
connected = false;
});
if (mounted) {
setState(() {
connected = false;
});
}
});
socket.onError((error) {
print("Socket error: $error");
Expand Down

0 comments on commit 519ff7d

Please sign in to comment.