If you have this error, you probably forgot to run the build
package. To do that, simply run the following command in your shell.
pub run build_runner build
It will generate the code that actually do the HTTP request (YOUR_FILE.chopper.dart). If you wish to update the code automatically when you change your definition run the watch
command.
pub run build_runner watch
Connection timeout is very limited for now due to http package (see: dart-lang/http#21)
But if you are on VM or Flutter you can set the connectionTimeout
you want
import 'package:http/io_client.dart' as http;
import 'dart:io';
final chopper = ChopperClient(
client: http.IOClient(
HttpClient()..connectionTimeout = const Duration(seconds: 60),
),
);
Possible using an interceptor.
final chopper = ChopperClient(
interceptors: [_addQuery],
);
Request _addQuery(Request req) {
final params = Map<String, dynamic>.from(req.parameters);
params['key'] = '123';
return req.replace(parameters: params);
}
Chopper is built on top of http
package and you can override the inner http client.
import 'dart:io';
import 'package:http/io_client.dart' as http;
final ioc = new HttpClient();
ioc.badCertificateCallback = (X509Certificate cert, String host, int port)
=> true;
final chopper = ChopperClient(
client: http.IOClient(ioc),
);