Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix Multipart for List<int> and List<String> #439

Merged
merged 21 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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