chopper
chopper copied to clipboard
Always retrieve NoSuchMethodError: The getter 'body' was called on null. Receiver: null Tried calling: body
Try to send Post request using Chopper. But I always have the following error "NoSuchMethodError: The getter 'body' was called on null. Receiver: null Tried calling: body" Service looks like:
@ChopperApi()
abstract class AppsService extends ChopperService {
@Post(path: 'emotions/', headers: {'content-type': 'application/json'})
Future<Response<RecordAnalysisDataModel>> uploadRecord(@Body() String body);
static AppsService create({AuthHelper authHelper}) {
final client = ChopperClient(
baseUrl: 'https://${Urls.API_URL}',
interceptors: [
HeaderInterceptor(authHelper),
TokenInterceptor(authHelper)
],
converter: JsonToTypeConverter({
RecordAnalysisDataModel: (json) => RecordAnalysisDataModel.fromJson(json),
}),
services: [
_$AppsService(),
],
);
return _$AppsService(client);
}
}
Call looks like:
@override
Future<Response<RecordAnalysisDataModel>> uploadText({RecordDataModel record}) {
var body = <String, dynamic>{
'text': record.text,
'recorded_at': record.recordingTime,
};
return _service.uploadRecord(jsonEncode(body));
}
I double checked that I send correct string as body, but still having the issue
I got same problem.
Could you retry with 4.0.1 version?