rawGraphFrom method

  1. @override
Object rawGraphFrom(
  1. Object value,
  2. {String typeName,
  3. FullType specifiedType,
  4. MapperEncodeContext context}
)
override

Implementation

@override
Object rawGraphFrom(
  Object value, {
  String typeName,
  FullType specifiedType,
  MapperEncodeContext context,
}) {
  if (value == null) {
    return null;
  } else if (value is pb.GeneratedMessage) {
    final fieldInfosByName = value.info_.byName;
    final result = <String, Object>{};
    for (var fieldName in fieldInfosByName.keys) {
      final fieldInfo = fieldInfosByName[fieldName];
      result[fieldName] = _dartToPb(value, fieldInfo);
    }
    return result;
  } else {
    throw ArgumentError.value(
      value,
      'value',
      'Should be a "package:protobuf" GeneratedMessage',
    );
  }
}