md_api_service 0.0.2 md_api_service: ^0.0.2 copied to clipboard
A Base API Service to use single Dio for multiple host and make model mapping easier.
import 'package:md_api_service/api_service.dart';
import 'api_service.dart';
import 'inputs/api_input.dart';
import 'models/todo.dart';
void main(List<String> arguments) async {
Log.logPrint = print;
final apiService = APIService();
final postTodoAPIInput = PostTodoAPIInput(todo: Todo(1, 1, 'abc', false));
try {
final response = await apiService.requestJSONObject(
postTodoAPIInput,
mapper: Todo.fromJson,
options: NetworkRequestOptions(
printToCurl: true,
),
);
Log.json(response);
} catch (error, stackTrace) {
Log.e('', time: DateTime.now(), error: error, stackTrace: stackTrace);
}
}