connectivity_plus 是一个 Flutter 插件,可让应用在 Android、iOS、Web、macOS、Windows 和 Linux 上检测并响应网络连接变化。它提供有关当前活动连接类型(如 WiFi、移动数据或无连接)的实时信息,使开发者能够构建适应网络可用性的健壮应用程序。该包提供了跨平台的简单且一致的 API,非常适合处理离线场景、同步数据或显示网络状态指示器。
适合场景
实时监控网络状态
优雅地处理离线模式
显示连接指示器
自动重试失败的请求
根据连接类型优化数据使用
主要特点
跨平台支持(Android、iOS、Web、macOS、Windows、Linux)
实时连接状态更新
检测WiFi和移动数据连接
同时支持初始状态和基于流的监控
简单直观的 API,设置最少
适合对象
需要可靠网络感知的应用程序
离线可用的应用程序
需要连接上下文的数据密集型服务
针对多个平台且行为一致的开发者
使用建议
在 Android 和 iOS 上需要平台特定的权限
Web 支持可能因浏览器而存在限制
无法检测互联网访问——仅本地连接
可能需要额外的逻辑来验证实际的互联网连通性
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Plus plugins
PlusPlugins is a set of Flutter plugins that is developed based on plugins, which previously existed
as a part of Flutter plugins, with extra functionalities,
support for more platforms and better maintenance.
Please file PlusPlugins specific issues, bugs, or feature requests in our issue tracker.
Plugin issues that are not specific to PlusPlugins can be filed in the Flutter issue tracker.
Contributing
If you wish to contribute a change to any of the existing plugins in this repo,
please review our contribution guide
and open a pull request.
Status
This repository is maintained by FlutterCommunity authors. Issues here are answered by maintainers and other community members on GitHub on a best-effort basis.