canDeserialize method

  1. @override
bool canDeserialize(
  1. Class type
)
override

Returns whether the given type can be deserialized by the system.

Implementations should determine if a registered deserializer or converter exists for the specified class type T.

Returns:

  • true → if the type can be deserialized into an object instance.
  • false → if no compatible deserializer is available.

Example

if (serializer.canDeserialize(Class<User>)) {
  final user = serializer.deserialize(parser, context, Class<User>());
}

Implementation

@override
bool canDeserialize(Class type) => type == Class<int>() || type.getType() == int;