Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bryanbill/fetch
Fetchx - Simplified http requests in Dart
https://github.com/bryanbill/fetch
collaborate dart dartlang flutter hacktoberfest http student-vscode
Last synced: about 2 months ago
JSON representation
Fetchx - Simplified http requests in Dart
- Host: GitHub
- URL: https://github.com/bryanbill/fetch
- Owner: bryanbill
- License: mit
- Archived: true
- Created: 2022-05-21T11:27:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-21T11:20:37.000Z (almost 2 years ago)
- Last Synced: 2024-09-25T19:20:08.385Z (about 2 months ago)
- Topics: collaborate, dart, dartlang, flutter, hacktoberfest, http, student-vscode
- Language: Dart
- Homepage: https://pub.dev/packages/fetchx
- Size: 161 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Fetchx
Fetchx is a simple, fast, and secure HTTP client for Dart. It leverages extensions to allow using url-like strings to make http requests.
[Read in another language](#translations)
## Table of contents
## Features
- Get
- Post
- Put
- Delete
- Patch## Usage
To use this package add this to your pubspec.yaml
```yaml
dependencies:
fetchx: ^0.0.5
```Then import the package
```dart
import 'package:fetchx/fetchx.dart';
```### Get
```dart
final response = await "https://jsonplaceholder.typicode.com/posts/1".get();
```
### Post
```dart
final response = await "https://jsonplaceholder.typicode.com/posts".post({
"title": "foo",
"body": "bar",
"userId": 1
});```
### Put
```dart
final response = await "https://jsonplaceholder.typicode.com/posts/1".put({
"title": "foo",
"body": "bar",
"userId": 1
});```
### Delete
```dart
final response = await "https://jsonplaceholder.typicode.com/posts/1".delete();
```
### Patch
```dart
final response = await "https://jsonplaceholder.typicode.com/posts/1".patch({
"title": "foo"
});```
## EXPERIMENTAL
These features are still experimental and may change in the future. Any feedback is welcome to improve the package.
### To Model Casting
```dart
class User extends BaseModel{
final int? id;
final String? name;
User({
this.id,
this.name
});@override
User fromJson(Map json) => User(
id: json["id"],
name: json["name"]
);
}final response = await "https://jsonplaceholder.typicode.com/users/1".get().to(()=>User());
print(response.name);```
### Cache
```dart
final response = await "https://jsonplaceholder.typicode.com/posts/1".get().cache();
```## Translations
This README is available in other languages:
- [English](README.md)
- [简体中文](README_zh_CN.md)