fromJson method Null safety

  1. @override
T fromJson(
  1. Object json
)
override

Implementation

@override
T fromJson(Object json) {
  if (json is Map<String, dynamic>) {
    if (json.containsKey('end_at')) {
      return RestrictedUser.fromJson(json) as T;
    } else if (json.containsKey('muted_end_at') ||
        json.containsKey('is_muted')) {
      return Member.fromJson(json) as T;
    } else {
      return User.fromJson(json) as T;
    }
  }
  return json as T;
}