decodeModelOrNull<T> function

T? decodeModelOrNull<T>(
  1. String jsonString,
  2. T decode(
    1. Map<String, dynamic> jsonMap
    )
)

Implementation

T? decodeModelOrNull<T>(String jsonString, T Function(Map<String, dynamic> jsonMap) decode) {
  try {
    final map = jsonDecode(jsonString);
    return decode(map);
  } catch (e) {
    return null;
  }
}