supports method

  1. @override
bool supports(
  1. DeserializationContext<Parser> context
)

Determines whether this deserializer supports the given deserialization context.

The method allows deserializers to indicate whether they can correctly handle input data within the provided context. This can include:

  • Inspecting configuration flags in the context
  • Checking type mappings or registered adapters
  • Ensuring compatibility with the target format (JSON, YAML, XML, etc.)

Returns:

  • true → if this deserializer can safely convert input data within the context
  • false → if the deserializer cannot handle data under the current context

Example

final context = DeserializationContext.default();
if (deserializer.supports(context)) {
  final user = deserializer.deserialize(map, context);
}

Notes

  • Used internally by the deserialization framework to dynamically select appropriate deserializers.
  • Implementations may consider format-specific capabilities, feature flags, or runtime conditions when deciding support.

Implementation

@override
bool supports(DeserializationContext context) => context is YamlDeserializationContext;