Search packages, repositories and app categories

Package detailsv1.2.1

fetch_client

Client for http package based on Fetch API, enables streamed and cancelable requests on web and more.

Web
30-day downloads
101K
Likes
44
Pub points
140

Install package

flutter pub add fetch_client

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Fetch_client is a Flutter package that provides a Fetch API-inspired interface for making HTTP requests, designed to work seamlessly on the web. It supports streamed responses and cancelable requests, enhancing performance and user experience in web applications. Built on top of the http package, it offers a modern, intuitive syntax while maintaining compatibility with Dart's asynchronous programming model. Ideal for developers seeking a familiar, efficient way to handle HTTP interactions in web-focused Flutter apps.

Use cases

  • Making HTTP requests in web-based Flutter apps
  • Handling streaming responses from APIs
  • Canceling ongoing requests during navigation
  • Implementing real-time data fetching
  • Building responsive web interfaces with async operations

Key features

  • Fetch API-like syntax
  • Support for streamed responses
  • Cancelable requests
  • Web-first design
  • Lightweight wrapper over http package

Suitable for

  • Web-focused Flutter developers
  • Apps requiring real-time data
  • Developers preferring modern HTTP patterns
  • Projects needing request cancellation
  • Teams using stream-based data flows

Considerations

  • Limited functionality outside web platform
  • Depends on http package for core operations
  • No native support for mobile platforms
  • Not suitable for complex HTTP scenarios beyond web
  • Requires careful handling of streams in web contexts

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Fetch Client

pub package package publisher

This package provides package:http client based on Fetch API with WASM support.

It's a drop-in solution for extensions with Manifest V3.

Features

  • WASM-ready internals.
  • Cancel requests.
  • Support data streaming:
    • Get response as Stream.
    • Optionally, send Stream as request body (supported only in Chromium 105+ based browsers).
  • Get access to redirect URL and status.
  • Support non-200 responses (fetch will only fail on network errors).
  • Simulate redirects responses via probe request and artificial location header.

Notes

Large payload

This module maps keepalive to BaseRequest.persistentConnection which is true by default.

Fetch spec says that maximum request size with keepalive flag is 64KiB:

4.5. HTTP-network-or-cache fetch

8.10.5: If the sum of contentLength and inflightKeepaliveBytes is greater than 64 kibibytes, then return a network error.

Source: Fetch. Living Standard — Last Updated 19 June 2023

Therefore if your request is larger than 64KiB (this includes some other data, such as headers) BaseRequest.persistentConnection will be ignored and treated as false.

Request streaming

Request streaming is supported only in Chromium 105+ based browsers and requires the server to use HTTP/2 or HTTP/3.

See MDN compatibility chart and Chrome Developers' blog for more info.

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package