chopper
chopper copied to clipboard
http.MultipartFile not found in auto generated chopper.dart
Hi, i've tried to add MultipartFile
which is from package:http/http.dart as http
but the auto generated chopper file return error.
Followed #55, #65
How do I send multiple Multipart files with same multipart key?
chopper: ^3.0.0
chopper_generator: ^3.0.0
// api_service.dart
...
import 'package:http/http.dart' as http;
...
@Post(path: "support/", headers: {"Authorization": ""})
@multipart
Future<Response> submitNewTicket({
...
@PartFile('attachment') List<http.MultipartFile> attachments,
});
...
// api_service.chopper.dart
Future<Response> submitNewTicket(
{List<MultipartFile> attachments}) { // error red line at `MultipartFile`
final $url = 'support/';
final $headers = {'Authorization': ''};
final $parts = <PartValue>[
PartValueFile<List<MultipartFile>>('attachment', attachments) // error red line at `MultipartFile`
];
final $request = Request('POST', $url, client.baseUrl,
parts: $parts, multipart: true, headers: $headers);
return client.send<dynamic, dynamic>($request);
}
@josephchenghmlet could you resolve your problem?
Hi @MahdiPishguy, I've switched todio
temporary for post multipartfile.
Welcome back @lejard-h
aliased import seems difficult to handle with source_gen, I can't find any resource to help me.
But you can change your import to import 'package:http/http.dart' show MultipartFile;
or just import 'package:http/http.dart';
Hi @lejard-h, thank you. Let me try and update you if there's outcome.
It's the exact same thing with BuiltValue
. From some reason, code generators, in general, are having difficulty with library aliases.
I think I'm having this same issue. If I
import 'package:chopper/chopper.dart' as ch;
then my generated code does NOT contain the import prefix.