jsonDecodeOrNull<T> function

T? jsonDecodeOrNull<T>(
  1. String input
)

Parses a JSON input into an object of type T, returning Null on failure.

Supported types:

Implementation

T? jsonDecodeOrNull<T>(String input) {
  try {
    final decoded = const JsonDecoder().convert(input);
    return decoded is T ? decoded : null;
  } catch (e) {
    return null;
  }
}