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

插件详情v0.0.3

sync_sphere

sync_sphere 包旨在以简单的方式检查整个应用程序或特定位置的互联网连接状态。只需包装您希望监听互联网连接的组件,其余工作交给我们即可。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
19
喜欢数
4
Pub 分数
110

安装插件

flutter pub add sync_sphere

插件介绍

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

sync_sphere 是一个 Flutter 包,可简化在您的应用或特定小部件中检查互联网连接。它允许开发人员将任何小部件包装在连接监听器中,根据网络状态变化自动更新。该包提供实时更新和最少的样板代码,使处理在线/离线状态变得简单。它支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,确保在各种环境中的行为一致。

适合场景

  • 监控特定UI区域的连接性
  • 显示离线指示器
  • 基于网络状态的条件渲染
  • 失败的 API 调用的自动重试逻辑
  • 离线时的优雅降级
  • 实时连接反馈

主要特点

  • 用于连接性监控的简单小部件包装
  • 实时网络状态更新
  • 跨平台支持
  • 最小化设置和配置
  • 内置的在线/离线状态管理
  • 轻便高效

适合对象

  • 需要可靠网络感知的应用程序
  • 寻求快速连接集成的开发者
  • 针对多个平台的项目
  • 需要动态在线/离线行为的UI
  • 重视开发者体验的团队

使用建议

  • 移动平台需要互联网权限
  • 如果过度使用,可能会频繁触发重建
  • 无法处理复杂的网络状况,例如慢速连接
  • 除了连接状态外,没有内置的重试机制
  • 高级网络诊断的自定义功能有限

原始 README

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

sync_sphere

A Flutter package for constant internet connectivity checking throughout the app.

Features

  • Monitors internet connectivity.
  • Displays a user-friendly screen when there is no internet connection.
  • Customizable options for the internet connectivity screen.

Getting Started

  1. Add the sync_sphere package to your pubspec.yaml file:
dependencies:
  sync_sphere: ^0.0.3
  1. Run pub get
flutter pub get
  1. import your package
import 'package:sync_sphere/sync_sphere.dart';
  1. Wrap child of your MaterialApp with the SyncSphere widget
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SyncSphere(
        child: YourMainScreen(),
        whenOffine: YourOfflineScreenWidget(),
      ),
    );
  }
}
  1. You can also use the default "No internet" widget
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SyncSphere(
        child: YourMainScreen(),
      ),
    );
  }
}

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。