搜索插件、代码仓与 APP 分类

插件详情v2.3.1

fetch_api

Fetch API 的 JavaScript 绑定,灵活的 HTTP 请求、重定向、流式传输等。

Web
近 30 天下载
9.6万
喜欢数
11
Pub 分数
140

安装插件

flutter pub add fetch_api

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

fetch_api 包为 Flutter Web 应用程序提供了类似 JavaScript 的 Fetch API 绑定,支持灵活且现代的 HTTP 请求。它支持重定向、流式响应和直观的请求处理,与浏览器原生 Fetch API 非常相似。专为 Web 平台设计,该包通过熟悉的接口简化了 HTTP 调用。该包轻量且可无缝集成到基于 Web 的 Flutter 项目中。

适合场景

  • 发送 HTTP GET 和 POST 请求
  • 处理流式响应
  • 自动管理重定向
  • 在Web应用程序中实现客户端API
  • 简化基于 fetch 的交互

主要特点

  • JavaScript Fetch API 兼容性
  • 流式响应支持
  • 自动重定向处理
  • 简单、可链式调用的语法
  • 仅限网络平台的目标

适合对象

  • 仅限 Web 的 Flutter 项目
  • 前端Web应用程序
  • 网页上的API集成
  • 熟悉 JavaScript fetch 的开发者
  • 需要轻量级 HTTP 客户端的项目

使用建议

  • 移动或桌面平台不可用
  • 仅限网页环境
  • 依赖浏览器的原生 fetch
  • 无内置错误重试逻辑
  • 需要仔细处理异步流

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Fetch API

pub package package publisher

This package provides WASM-ready Dart bindings to JavaScript Fetch API.

Features

  • Full fetch options / request parameters coverage
  • Cancel requests via AbortController.
  • Read response
    • As text (String)
    • As Blob
    • As Stream of Uint8List
  • Response streaming
  • Request streaming (check compatibility)
  • Get access to redirect status
  • Support non-200 responses

Some notes about fetch and Request

fetch and Request have same options but different semantics, e.g. fetch's default mode is no-cors while Request's cors. Therefore, options objects of fetch function and Request constructor made as different extension types, although they are interchangeable and both inherited from RequestInit.

For more info about that, read MDN docs.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目