retrofit.dart
retrofit.dart copied to clipboard
fix: Add Missing Mapping of DateTime in Multipart
Problem
If we have a request like this:
@MultiPart()
@POST('/api/some/path/')
Future<SomeResponse> requestName({
@Part(name: 'full_name') required String fullName,
@Part(name: 'birth_date') required DateTime birthDate,
we'll get a toJson() method have to add to DateTime
Exception.
Solution
If part param doesn't have the toJson()
method, we have to check whether this is DateTime. If so, we use atoIso8601String
method.