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

插件详情v0.3.1

sync_http

Dart 的同步 HTTP 客户端。

AndroidiOSmacOSWindowsLinux
近 30 天下载
959万
喜欢数
16
Pub 分数
120

安装插件

flutter pub add sync_http

插件介绍

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

sync_http 是 Dart 的同步 HTTP 客户端,旨在简化在异步操作不理想环境中的 HTTP 请求。它提供了一个简单的 API,用于同步执行 GET、POST、PUT 等 HTTP 方法,阻塞执行直到收到响应。这使其适用于需要简单线性控制流的场景,例如命令行工具或脚本。该包由 Google 维护,支持 Android、iOS、macOS、Windows 和 Linux 多个平台。

适合场景

  • 命令行工具
  • 脚本工作流
  • 简单数据获取
  • 同步后端处理
  • 测试 HTTP 交互

主要特点

  • 同步请求处理
  • 简单直观的 API
  • 跨平台支持
  • 轻便且简约
  • 内置错误处理

适合对象

  • 需要阻塞式HTTP调用的开发者
  • 非UI应用程序
  • 原型设计与测试
  • 旧代码集成
  • 简单的自动化脚本

使用建议

  • 由于具有阻塞特性,不适用于UI线程
  • 与异步替代方案相比,可扩展性有限
  • 在高吞吐量场景下可能导致性能问题
  • 仅在非交互式上下文中使用最佳

原始 README

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

Dart CI pub package package publisher

A Dart HTTP client implemented using RawSynchronousSockets to allow for synchronous HTTP requests.

Using this package

Note: this package is only intended for very specialized use cases. For general HTTP usage, please see instead package:http.

This library should probably only be used to connect to HTTP servers that are hosted on 'localhost'. The operations in this library will block the calling thread to wait for a response from the HTTP server. The thread can process no other events while waiting for the server to respond. As such, this synchronous HTTP client library is not suitable for applications that require high performance. Instead, such applications should use libraries built on asynchronous I/O, including dart:io and package:http, for the best performance.

所属分类

源码仓库

使用此插件的项目