fromJSON method Null safety

  1. @override
Object? fromJSON(
  1. dynamic jsonValue,
  2. DeserializationContext context
)
override

Implementation

@override
Object? fromJSON(dynamic jsonValue, DeserializationContext context) {
  dynamic convert(value) =>
      _enumDescriptor!.values.firstWhereOrNull((eValue) =>
          _enumDescriptor!.caseInsensitive == true
              ? _transformValue(value, context).toLowerCase() ==
                  _transformValue(eValue, context, doubleMapping: true)
                      .toLowerCase()
              : _transformValue(value, context) ==
                  _transformValue(eValue, context, doubleMapping: true)) ??
      _enumDescriptor!.defaultValue;
  return jsonValue is Iterable
      ? jsonValue.map(convert).toList()
      : convert(jsonValue);
}