Skip to content

Commit

Permalink
🐛 fix Multipart for List<int> and List<String> (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse authored Jun 3, 2023
1 parent 829d5b0 commit 455cd34
Show file tree
Hide file tree
Showing 4 changed files with 409 additions and 211 deletions.
17 changes: 11 additions & 6 deletions chopper/lib/src/request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,18 @@ class Request extends http.BaseRequest with EquatableMixin {
);
} else {
throw ArgumentError(
'Type ${part.value.runtimeType} is not a supported type for PartFile'
'Please use one of the following types'
' - List<int>'
' - String (path of your file) '
' - MultipartFile (from package:http)',
'Type ${part.value.runtimeType} is not a supported type for PartFile. '
'Please use one of the following types:\n'
'- List<int>\n'
'- String (path of your file)\n'
'- MultipartFile (from package:http)',
);
}
} else if (part.value is Iterable) {
request.fields.addAll({
for (int i = 0; i < part.value.length; i++)
'${part.name}[$i]': part.value.elementAt(i).toString(),
});
} else {
request.fields[part.name] = part.value.toString();
}
Expand Down Expand Up @@ -251,7 +256,7 @@ class PartValue<T> with EquatableMixin {
];
}

/// Represents a file part in a multipart request.
/// Represents a file [PartValue] in a multipart request.
@immutable
class PartValueFile<T> extends PartValue<T> {
const PartValueFile(super.name, super.value);
Expand Down
Loading

0 comments on commit 455cd34

Please sign in to comment.