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

How to pass complex object as parameter #5

Closed
sherifhasan opened this issue Feb 26, 2019 · 1 comment
Closed

How to pass complex object as parameter #5

sherifhasan opened this issue Feb 26, 2019 · 1 comment

Comments

@sherifhasan
Copy link

The following code throws Converting object to an encodable object failed: Instance of 'InvocationMessage'

_hubConnection.invoke("Broadcast", args: [request, broadMessage]);

I already implemented toJson() as per instruction
use objects that implements toJson() since that method is used by the dart:convert package to serialize an object. here https://pub.dartlang.org/packages/signalr_client

class NotificationRequest {
  int connectionType;
  String command;
  int userId;
  String userName;
  String uuid;

  NotificationRequest(
      {this.command,
      this.connectionType,
      this.userId,
      this.userName,
      this.uuid});

  Map<String, dynamic> toJson() => {
        'connectionType': connectionType,
        'command': command,
        'userId': userId,
        'userName': userName,
        'uuid': uuid
      };
}
class BroadCastMessage {
  String message;
  BroadCastMessage({this.message});
  Map<String, dynamic> toJson() => {'message': message};
}
@soernt
Copy link
Owner

soernt commented Feb 26, 2019

This should be fixed within the new version 0.1.5.
Thank you for reporting the bug!
There is a test for this.

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

No branches or pull requests

2 participants