Fetchx

一个用于发起 HTTP 请求的 Dart/Flutter 包。

特点

  • Get(获取)
  • 帖子
  • Put
  • Delete(删除)
  • Patch

用法

要使用此包,请将其添加到你的 pubspec.yaml 文件中

dependencies:
  fetchx: ^0.0.1

然后导入该包

import 'package:fetchx/fetchx.dart';

Get(获取)

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

帖子

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

GitHub

查看 Github