Closed sherifhasan closed 5 years ago
The following code throws Converting object to an encodable object failed: Instance of 'InvocationMessage'
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
toJson()
use objects that implements toJson() since that method is used by the dart:convert package to serialize an object.
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}; }
This should be fixed within the new version 0.1.5. Thank you for reporting the bug! There is a test for this.
The following code throws
Converting object to an encodable object failed: Instance of 'InvocationMessage'
I already implemented
toJson()
as per instructionuse 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