패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.1

fetch_client

Fetch API를 기반으로 한 http 패키지용 클라이언트로, 웹에서 스트리밍 및 취소 가능한 요청을 가능하게 하고, 더 많은 기능을 제공합니다.

Web
30일 다운로드
10.1만
좋아요
44
Pub 점수
140

패키지 설치

flutter pub add fetch_client

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Fetch_client는 웹에서 원활하게 작동하도록 설계된 HTTP 요청을 위한 Fetch API를 모방한 인터페이스를 제공하는 Flutter 패키지입니다. 스트리밍 응답과 취소 가능한 요청을 지원하여 웹 애플리케이션의 성능과 사용자 경험을 향상시킵니다. http 패키지 위에 구축되어 있으며, Dart의 비동기 프로그래밍 모델과 호환되면서도 현대적이고 직관적인 문법을 제공합니다. 웹 중심의 Flutter 앱에서 HTTP 상호작용을 친숙하고 효율적으로 다루고자 하는 개발자에게 이상적입니다.

사용 사례

  • 웹 기반의 Flutter 앱에서 HTTP 요청하기
  • API에서 스트리밍 응답 처리
  • 네비게이션 중 진행 중인 요청 취소
  • 실시간 데이터 가져오기 구현
  • 비동기 작업을 사용하여 반응형 웹 인터페이스 구축

주요 기능

  • Fetch API 유사 구문
  • 스트리밍 응답 지원
  • 취소 가능한 요청
  • 웹 우선 디자인
  • http 패키지에 대한 가벼운 래퍼

적합한 대상

  • 웹 중심의 플러터 개발자
  • 실시간 데이터가 필요한 앱
  • 현대적인 HTTP 패턴을 선호하는 개발자
  • 요청 취소가 필요한 프로젝트
  • 스트림 기반 데이터 흐름을 사용하는 팀

고려 사항

  • 웹 플랫폼 외부에서는 기능이 제한됩니다
  • 핵심 작업을 위해 http 패키지에 의존합니다
  • 모바일 플랫폼에 대한 내장 지원 없음
  • 웹을 넘어서는 복잡한 HTTP 시나리오에는 적합하지 않습니다
  • 웹 컨텍스트에서 스트림을 주의 깊게 다뤄야 합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

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.

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트