Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_reconstructPacket #294

Closed
jingen11 opened this issue Oct 6, 2022 · 2 comments
Closed

_reconstructPacket #294

jingen11 opened this issue Oct 6, 2022 · 2 comments
Labels

Comments

@jingen11
Copy link

jingen11 commented Oct 6, 2022

  static Object? _reconstructPacket(Object data, List<List> buffers) {
    if (data is List) {
      final _data = data;
      int i = 0;
      _data.forEach((v) {
        _data[i++] = _reconstructPacket(v, buffers);
      });
      return _data;
    } else if (data is Map) {
      final _data = data;
      if ('${_data[KEY_PLACEHOLDER]}'.toLowerCase() == 'true') {
        final knum = _data[KEY_NUM]!;
        int num = knum is int ? knum : int.parse(knum).toInt();
        return num >= 0 && num < buffers.length ? buffers[num] : null;
      }
      data.forEach((key, value) {
        _data[key] = _reconstructPacket(value, buffers);
      });
      return _data;
    }
    return data;
  }

I have encountered this error Unhandled Exception: type 'Null' is not a subtype of type 'Object' while receiving acknowledgement from the server. The reason being one of my value of the map is null.

Is it possible if the signature of the function be changed to static Object? _reconstructPacket(Object? data, List buffers) ?

@jingen11
Copy link
Author

jingen11 commented Oct 6, 2022

This function is from socket_io_common.

@jumperchen
Copy link
Member

please update socket_io_common with 2.0.1 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants