/// User classes
class UserBase {
String id;
}
class User implements UserBase {
String id;
String name;
}
/// Group classes
class GroupBase {
String id;
}
// this class is used as a Request Message on RPC
class GroupMessage<TUser extends UserBase> implements GroupBase {
String id;
String name;
String surName;
List<TUser> members;
GroupMessage() {
members = List<TUser>();
}
}
class Group implements GroupMessage<User> {
String id;
String name;
String surName;
List<User> members;
Group() {
members = List<User>();
}
String get completeName => this.name + ' ' + this.surName;
}
The following error is thrown when an instance of GroupMessage class defined with Generics is passed as a Request Param from Client to Server-Side on RPC and the RPC try to materialize an new instance on Server-Side from Json:
Field members has wrong type: type 'List<dynamic>' is not a subtype of type 'List<UserBase>' of 'value'
NOTE 1: This error occurs with SDK 2.0.0 + Generics. In SDK 2.1.0-dev.8.0 this error occurs using normal class without Generics too, like reported on issue https://github.com/dart-lang/rpc/issues/133
NOTE 2:: This error occurs when it's used Generic into List<T> field as in the example above: List<TUser> members;
SDK 2.0.0 RPC 0.6.0
Considering the following classes:
The following error is thrown when an instance of
GroupMessage
class defined with Generics is passed as a Request Param from Client to Server-Side on RPC and the RPC try to materialize an new instance on Server-Side from Json:NOTE 1: This error occurs with SDK 2.0.0 + Generics. In SDK 2.1.0-dev.8.0 this error occurs using normal class without Generics too, like reported on issue https://github.com/dart-lang/rpc/issues/133
NOTE 2:: This error occurs when it's used Generic into
List<T>
field as in the example above:List<TUser> members;