https://github.com/hamas-ur-rehman/httpservice
This package contains classes that make it easy to consume the http package. It's multi-platform, and supports mobile, desktop, and the browser. It supports GET,PUT,POST,DELETE and PATCH requests. It Depends on the http package
https://github.com/hamas-ur-rehman/httpservice
classes dart dart-library flutter flutterpackage hacktoberfest http http-server serverrequestinterface
Last synced: 5 days ago
JSON representation
This package contains classes that make it easy to consume the http package. It's multi-platform, and supports mobile, desktop, and the browser. It supports GET,PUT,POST,DELETE and PATCH requests. It Depends on the http package
- Host: GitHub
- URL: https://github.com/hamas-ur-rehman/httpservice
- Owner: Hamas-ur-Rehman
- License: mit
- Created: 2021-07-31T08:53:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-03T04:07:31.000Z (over 4 years ago)
- Last Synced: 2025-11-27T17:11:37.357Z (3 months ago)
- Topics: classes, dart, dart-library, flutter, flutterpackage, hacktoberfest, http, http-server, serverrequestinterface
- Language: C++
- Homepage:
- Size: 105 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# httpservice
A FLutter package that depends on http package.
## Getting Started
This package contains classes that make it
easy to consume the http package. It's multi-platform, and supports mobile, desktop,
and the browser.
It supports GET,PUT,POST,DELETE and PATCH requests
## Using
The easiest way to use this library is to initialize the class and call the function:
```dart
import 'dart:convert';
import 'package:httpservice/httpservice.dart';
void getapidata(String apix) async {
HttpService httpService = HttpService("$apix");
var data = await httpService.getContents();
var decodedData = jsonDecode(data);
print(decodedData);
}
```
### GET
```dart
import 'dart:convert';
import 'package:httpservice/httpservice.dart';
void getapidata(String apix) async {
HttpService httpService = HttpService("$apix");
var data = await httpService.getContents();
var decodedData = jsonDecode(data);
print(decodedData);
}
```
### POST
```dart
import 'dart:convert';
import 'package:httpservice/httpservice.dart';
void postapidata(String apix) async {
HttpService httpService = HttpService("$apix");
var data = await httpService.postContents(headers: {"Content-type": "application/json"},body: '{"title": "Hello", "body": "body text", "userId": 1}');
}
```
### PUT
```dart
import 'dart:convert';
import 'package:httpservice/httpservice.dart';
void postapidata(String apix) async {
HttpService httpService = HttpService("$apix");
var data = await httpService.putContents(headers: {"Content-type": "application/json"},body:'{"title": "Hello", "body": "body text", "userId": 1}');
}
```
### PATCH
```dart
import 'dart:convert';
import 'package:httpservice/httpservice.dart';
void postapidata(String apix) async {
HttpService httpService = HttpService("$apix");
var data = await httpService.putContents(headers: {"Content-type": "application/json"},body:'{"title": "Hello"}');
}
```
### DELETE
```dart
import 'dart:convert';
import 'package:httpservice/httpservice.dart';
void postapidata(String apix) async {
HttpService httpService = HttpService("$apix");
var data = await httpService.deleteContents();
}
```