パッケージ、リポジトリ、アプリカテゴリを検索

connectivity_widget のカバー
パッケージ詳細v3.0.0

connectivity_widget

電話がインターネットに接続されているかどうかをユーザーに表示するウィジェット

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
324
いいね数
88
Pub ポイント
140

パッケージをインストール

flutter pub add connectivity_widget

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

connectivity_widget パッケージは、デバイスの現在のインターネット接続状態を表示するシンプルでリアクティブなウィジェットを提供します。Android、iOS、Web、macOS、Windows、Linux の各プラットフォームでネットワークの利用可能性を監視し、接続状態が変化したときにUIをリアルタイムで更新します。統合が簡単で、開発者がユーザーにオンラインまたはオフラインであることを知らせるための視覚的インジケーター(アイコンやテキストなど)を表示できるように設計されています。メッセージング、メディアストリーミング、データ同期サービスなど、ネットワーク状態に対する即時フィードバックが必要なアプリに最適です。

用途

  • リアルタイムネットワーク状態表示
  • オフラインモードインジケーター
  • 接続変更時のユーザーエクスペリエンスの向上
  • ネットワーク状態に応じたアプリ機能の適応
  • 通信状態が悪いときにステート管理を読み込み中

主な機能

  • クロスプラットフォーム対応
  • リアクティブUIの更新
  • 最小限のセットアップでシンプルな統合
  • カスタマイズ可能な外観
  • 接続変更の自動検出

適している対象

  • リアルタイムのネットワーク認識を必要とするアプリ
  • 軽量な接続モニタリングを求める開発者
  • 動的なネットワークフィードバックを必要とするUIコンポーネント
  • 複数のプラットフォームをターゲットにするプロジェクト
  • 即時オンライン/オフラインステータスインジケーターを希望するユーザー

注意事項

  • モバイルプラットフォームでの適切な権限が必要です
  • 一時的なネットワーク状態を処理するための追加ロジックが必要になる可能性があります
  • 特定のネットワークタイプ(例:Wi-Fi とセルラー)を処理しない
  • 接続状態に限定され、帯域幅や品質は含まれない
  • 正確性は下位プラットフォームAPIに依存します

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

connectivity_widget

A widget that shows the user if the phone is connected to the internet or not

This is accomplished not only by verifying the status of the mobile network and/or wifi, but also by pinging a remote server and verifying its response.

Example

Using the ConnectivityWidget

The ConnectivityWidget uses a builder function that provides you a isOnline flag to build different screens for offline or online mode.

 ConnectivityWidget(
        builder: (context, isOnline) => Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text("${isOnline ? 'Online' : 'Offline'}", style: TextStyle(fontSize: 30, color: isOnline ? Colors.green : Colors.red),),
              SizedBox(height: 20,),
              Text(
                'Number of times we connected to the internet:',
              ),
              Text(
                '$_counter',
                style: Theme.of(context).textTheme.display1,
              ),
            ],
          ),
        )

It also provides both a onlineCallback and a offlineCallback that are called when the phone changes the connection state to online and offline, respectively.

 ConnectivityWidget(
        onlineCallback: _incrementCounter,
        builder: //...,
        )

If there is a need to change the default offline banner, a Widget can be provided to the offlineBanner parameter. Additionally, its visibility can be enabled or disabled by using the showOfflineBanner parameter.

Configurable Parameters:

  • serverToPing;
  • timeoutDuration;
  • debounceDuration;
  • verifyResponseCallback;

Changing the server to ping and the response verification

By default, the Connectivity Widget checks if there is a connection to http://www.google.com. If you want to check the availability of a custom endpoint, you can set a new endpoint to ping and a callback to verify the response.

ConnectivityUtils.instance.setCallback((response) => response.contains("This is a test!"));
ConnectivityUtils.instance.setServerToPing("https://gist.githubusercontent.com/Vanethos/dccc4b4605fc5c5aa4b9153dacc7391c/raw/355ccc0e06d0f84fdbdc83f5b8106065539d9781/gistfile1.txt");
Using ConnectivityUtils to Listen to Network Changes

This library also provides access to the ConnectivityUtils class in which you can verify the status of the network.

Stream<bool> ConnectivityUtils.instance.isPhoneConnectedStream // gets the current status of the network
Future<bool> ConnectivityUtils.instance.isPhoneConnected() // future that determines network status
Note on Web:

Although we can verify the status of the connection in web, what happens is that browsers will cache a request to a specific endpoint, so we cannot verify for certain if the connection is down or if we are using cache, using the methods presented in this package.

カテゴリー

依存関係

依存関係一覧 5 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。