chopper_client_wrapper 1.0.1+2 chopper_client_wrapper: ^1.0.1+2 copied to clipboard
This package is a wrapper class that you can use to save time while setting up files for integrating apis. You just have to extend our class and follow the steps.
import 'dart:async';
import 'package:chopper/chopper.dart';
import 'package:chopper_client_wrapper/ChopperService/ChopperClientWrapper.dart';
void main() {}
class MyChopperClient extends ChopperClientWrapper {
/// Example
/// LoginResponseModel : LoginResponseModel.fromJson
/// We have a model caled LoginRsponseModel which is model for the response that comes when user login successfully
/// LoginResponseModel.fromJson is factory constructor of LoginResponseModel that converts Map to LoginResponseModel object
@override
Map<Type, JsonConvertorFunction> get jsonToModelConvertorMap => {};
@override
Map<Type, JsonConvertorFunction> get jsonToErrorModelConvertorMap =>{};
/// My base url
@override
String get baseUrl => 'https://myapi.com';
@override
List<ChopperService> get chopperServices => [
// List of Chopper services that you create for your application
];
/// return a token that will be used for authentication inside header
@override
FutureOr<String> getToken() {
return 'mytoken';
}
/// you can even set header parameters here if you want to change default set in the package
@override
Map<String, String> getHeaderParameters(){
return {};
}
}