搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案