tryCast<T> method

T? tryCast<T>(
  1. T fromJson(
    1. JsonMap doc
    )
)

Attempts to cast the full document payload to a typed object.

Returns null if the full document is not present or conversion fails.

Implementation

T? tryCast<T>(T Function(JsonMap doc) fromJson) {
  if (fullDocument == null) {
    return null;
  }
  try {
    return fromJson(fullDocument!);
  } catch (_) {
    return null;
  }
}