api_caller 1.0.7
api_caller: ^1.0.7 copied to clipboard
A lightweight helper for making HTTP API calls using Dart.
api_caller #
A lightweight and reusable Dart/Flutter utility for making HTTP API requests easier using the http package.
Features #
- Simplifies
GET,POST,PUT,PATCH, andDELETEHTTP methods - Optional headers and body support
- Graceful error handling
- Works with any RESTful API
- Easy to use in both Flutter and Dart apps
Getting Started #
1. Add it to your pubspec.yaml: #
dependencies:
<<<<<<< HEAD
api_caller: ^1.0.7
=======
api_caller: ^1.0.6
>>>>>>> fdadde1389f201657b4f8fcd3b58993e28fb54d4
import 'package:api_caller/api_caller.dart';
void fetchData() async {
final response = await ApiHelperBase.get('https://jsonplaceholder.typicode.com/posts');
if (response != null && response.statusCode == 200) {
print(response.body);
} else {
print('Failed to fetch data');
}
}
Supported Methods
ApiHelperBase.get(url);
ApiHelperBase.post(url, body: 'key=value');
ApiHelperBase.put(url, body: 'key=value');
ApiHelperBase.patch(url, body: 'key=value');
ApiHelperBase.delete(url);