Skip to content

Commit f9def19

Browse files
committed
Fixing lastState bug.
1 parent d4bf5df commit f9def19

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/src/socket_connection.dart

+7-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ final class _ConnectionCallbacks {
273273
String get attemptIdString => attempt.idAsString;
274274
final SocketConnectionManager manager;
275275

276-
WebSocketConnectionState lastState = const WebSocketReady._();
276+
WebSocketConnectionState? lastState;
277277

278278
void onMessage(String message) {
279279
if (attempt != manager._currentAttempt) {
@@ -347,8 +347,13 @@ final class _ConnectionCallbacks {
347347
manager._onStateChange(newState);
348348
}
349349

350-
bool _isTransitionAllowed(lastState, newState) {
350+
bool _isTransitionAllowed(
351+
WebSocketConnectionState? lastState,
352+
WebSocketConnectionState newState,
353+
) {
351354
switch ((lastState, newState)) {
355+
case (null, _):
356+
return true;
352357
case (final a, final b) when a == b:
353358
case (_, WebSocketInitializing()):
354359
case (WebSocketClosed(), _):

0 commit comments

Comments
 (0)