http_services 3.0.0 http_services: ^3.0.0 copied to clipboard
A Dart package based on Dio that provides base models to handle HTTP services requests.
import 'package:http_services/http_services.dart';
import 'todos_service.dart';
void main() async {
final dio = Dio(
BaseOptions(
baseUrl: 'https://jsonplaceholder.typicode.com/',
),
);
final service = TodosService(dio);
try {
print("Requesting data...");
final response1 = await service.getTodo(1);
print(
"user id: ${response1.userId}\n"
"id: ${response1.id}\n"
"title: ${response1.title}\n"
"completed: ${response1.completed}",
);
final response2 = await service.postBoh();
print(response2);
} on HttpServiceException catch (e) {
print('Service exception: ${e.runtimeType}');
}
}