fetchx 0.0.6 copy "fetchx: ^0.0.6" to clipboard
fetchx: ^0.0.6 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.

Read in another language

Table of contents #

Features #

  • Get
  • Post
  • Put
  • Delete
  • Patch

Usage #

To use this package add this to your pubspec.yaml

dependencies:
  fetchx: ^0.0.5
copied to clipboard

Then import the package

import 'package:fetchx/fetchx.dart';
copied to clipboard

Get #


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

copied to clipboard

Post #


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

copied to clipboard

Put #


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

copied to clipboard

Delete #


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

copied to clipboard

Patch #


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

copied to clipboard

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);

copied to clipboard

Cache #

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

Translations #

This README is available in other languages:

6
likes
160
points
47
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.26 - 2025.04.10

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