jamiewest / signalr_core

ASP.NET Core SignalR Dart Client
https://pub.dev/packages/signalr_core
MIT License
90 stars 58 forks source link

InvocationMessageExtensions: useless (and dangerous) cast to Object should be removed #68

Closed xit0c closed 2 years ago

xit0c commented 3 years ago

In InvocationMessageExtensions.fromJson, json['arguments'] is mapped to a list of items, each one casted to Object. Besides being a useless cast (since InvocationMessage.arguments is still defined as List<dynamic>) it is also dangerous because if arguments contains null the cast will fail and an exception will be thrown.

https://github.com/jamiewest/signalr_core/blob/00a3cb78ea93b9b2d243f0b2cb2900ea485fdb7b/lib/src/json_hub_protocol.dart#L185

I suggest to remove the map function and assign arguments directly to json['arguments'] as List?, leaving to the consumer of the message the responsibility of managing the list.