HttpBody.fromJson constructor

HttpBody.fromJson(
  1. Object? j
)

Implementation

factory HttpBody.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return HttpBody(
    contentType: switch (json['contentType']) {
      null => '',
      Object $1 => decodeString($1),
    },
    data: switch (json['data']) {
      null => Uint8List(0),
      Object $1 => decodeBytes($1),
    },
    extensions: switch (json['extensions']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Any.fromJson(i)],
      _ => throw const FormatException('"extensions" is not a list'),
    },
  );
}