Easy HTTP
Easy HTTP is a lightweight Flutter package that simplifies HTTP requests, making it effortless to perform GET, POST, PUT, and DELETE operations. With an intuitive API, you can start making network requests right away without any complex setup.
Features
- 🚀 Simple and intuitive API for HTTP requests
- 🔧 Supports GET, POST, PUT, and DELETE methods out of the box
- 🎯 Minimal setup required - start using it immediately
- 🔄 Easy handling of JSON data
- 🛠Customizable headers and request parameters
Getting started
To use this package, add ez_http
as a dependency in your pubspec.yaml
file:
dependencies:
ez_http: ^1.0.8
Then run dart pub get
or flutter pub get
to install the package.
Usage
Here are some quick examples to get you started with Easy HTTP:
GET Request
import 'package:ez_http/ez_http.dart';
void main() async {
Map<String, dynamic> response = await EasyHttp.get<Map<String, dynamic>>(
'https://api.example.com/users',
responseBodyType: ResponseBodyType.json,
);
final response2 = await EasyHttp.get(
'https://api.example.com/users2',
responseBodyType: ResponseBodyType.json,
);
print(response.body);
}
POST Request
import 'package:ez_http/ez_http.dart';
void main() async {
Map<String, dynamic> response = await EasyHttp.post<Map<String, dynamic>>(
'https://api.example.com/users',
body: {'name': 'John Doe', 'email': 'john@example.com'},
responseBodyType: ResponseBodyType.json,
contentType: ContentType.json,
);
print(response.statusCode);
print(response.body);
}
PUT Request
import 'package:ez_http/ez_http.dart';
void main() async {
Map<String, dynamic> response = await EasyHttp.put<Map<String, dynamic>>(
'https://api.example.com/users/1',
body: {'name': 'Jane Doe'},
responseBodyType: ResponseBodyType.json,
contentType: ContentType.json,
);
print(response.statusCode);
}
DELETE Request
import 'package:ez_http/ez_http.dart';
void main() async {
Map<String, dynamic> response = await EasyHttp.delete<Map<String, dynamic>>(
'https://api.example.com/users/1',
);
print(response.statusCode);
}
Additional information
For more detailed examples and advanced usage, please check out the /example
folder in the package repository.
Contributing
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please file an issue on the GitHub repository.
License
This package is released under the MIT License. See the LICENSE file for details.