我已经为我的 Fluter 项目配置了BLoC
+ ,并且到目前为止一切正常。目前,集成上传,我从侧面面临一些问题,我不知道它是什么以及如何解决这个问题。Chopper
API
File
API
Chopper
@Post(path: "FILE_UPLOAD_URL")
@multipart
Future<Response<ProfileResponse>> uploadUserProfilePic(
@Header("Authorization") String token,
@PartFile('file') List<int> file,
);
API调用:
await SharedPreferenceHelper.getToken().then(
(token) async {
final bytes = (await File(event.file.path).readAsBytes()).toList();
final file = http.MultipartFile.fromBytes('file', bytes);
profileResponse =
await Provider.of<ApiService>(context, listen: false)
.uploadUserProfilePic(token, bytes);
},
);
它从这个方法和文件( )中抛出NoSuchMethodError
异常,object_patch.dart
@patch
@pragma("vm:entry-point", "call")
dynamic noSuchMethod(Invocation invocation) {
// TODO(regis): Remove temp constructor identifier 'withInvocation'.
throw new NoSuchMethodError.withInvocation(this, invocation);
}