fetchx 0.0.8-dev.1 copy "fetchx: ^0.0.8-dev.1" to clipboard
fetchx: ^0.0.8-dev.1 copied to clipboard

Fetchx is a simple, fast, and secure HTTP client for Dart. It leverages extensions to allow using url-like strings to make http requests.

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.

Documentation #

Read in another language

Installation #

To use this package add this to your pubspec.yaml

dependencies:
  fetchx: ^latest

Then import the package

import 'package:fetchx/fetchx.dart';

How To #

Get #


final response = await "https://jsonplaceholder.typicode.com/posts/1".get();

Post #


final response = await "https://jsonplaceholder.typicode.com/posts".post({
  "title": "foo",
  "body": "bar",
  "userId": 1
});

Put #


final response = await "https://jsonplaceholder.typicode.com/posts/1".put({
  "title": "foo",
  "body": "bar",
  "userId": 1
});

Delete #


final response = await "https://jsonplaceholder.typicode.com/posts/1".delete();

Patch #


final response = await "https://jsonplaceholder.typicode.com/posts/1".patch({
  "title": "foo"
});

final response = await "https://jsonplaceholder.typicode.com/posts/1".head();

Download #

final file = await "https://jsonplaceholder.typicode.com/posts/1".download();

EXPERIMENTAL #

These features are still experimental and may change in the future. Any feedback is welcome to improve the package.

To Model Casting #

class User extends BaseModel{
  final int? id;
  final String? name;
  User({
     this.id,
     this.name
  });

  @override
  User fromJson(Map<String, dynamic> json) => User(
        id: json["id"],
        name: json["name"]
      );
}

final response = await "https://jsonplaceholder.typicode.com/users/1".get().to<User>(()=>User());
print(response.name);

Cache #

final response = await "https://jsonplaceholder.typicode.com/posts/1".get().cache();

Contributing #

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Translations #

This README is available in other languages:

License #

This project is licensed under the MIT License - see the LICENSE file for details

6
likes
140
pub points
0%
popularity

Publisher

unverified uploader

Fetchx is a simple, fast, and secure HTTP client for Dart. It leverages extensions to allow using url-like strings to make http requests.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

hive

More

Packages that depend on fetchx