FetchFeatures class final

可选的 Fetch API features,由平台 HTTP 客户端提供 fetch 实现。

原生平台通过 package:http(底层为 dart:ioHttpClient)发起请求; Web 平台使用浏览器原生 fetch

传入非空的 allowedOrigins 可限制请求与重定向只能访问列出的 HTTP(S) 源; 留空或 null 表示允许所有 HTTP(S) 源。

Inheritance

Constructors

FetchFeatures({Set<String>? allowedOrigins, Duration timeout = const Duration(seconds: 30), int maxRequestBytes = 1024 * 1024, int maxResponseBytes = 10 * 1024 * 1024, int maxRedirects = 5, Map<String, String> defaultHeaders = const <String, String>{}})
创建 Fetch features。
factory
FetchFeatures.session(JsHttpSession session)
使用一个会话的 Client、限制和默认 Header 创建 Fetch/XHR features。
factory

Properties

allowedOrigins Set<String>?
Exact normalized HTTP(S) origins this features may access.
final
browserGlobals JsGlobals
Browser-like global aliases installed before scripts.
finalinherited
defaultHeaders Map<String, String>
Headers merged into every request unless overridden by JavaScript.
final
hashCode int
The hash code for this object.
no setterinherited
maxRedirects int
Maximum number of redirects followed by one request.
final
maxRequestBytes int
Maximum encoded request body size.
final
maxResponseBytes int
Maximum streamed response body size.
final
methods List<JsHostMethod>
注入 JavaScript 的 Dart/Flutter 宿主方法。
finalinherited
modules List<JsModule>
ES module and CommonJS definitions included in this features.
finalinherited
name String
Stable name used for conflict detection and debug inspection.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scripts List<JsScript>
Ordered scripts that complete the runtime global environment.
finalinherited
session JsHttpSession?
可选的共享网络会话;为空时保持原有的单请求 Client 行为。
final
timeout Duration
Maximum duration for request headers and response body consumption.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited