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

パッケージ詳細v1.0.2

internet_connectivity_checker

デバイスのインターネット接続状態に基づいて、ウィジェットを簡単に動的に管理するのに役立つFlutterパッケージです。

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
458
いいね数
38
Pub ポイント
160

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

flutter pub add internet_connectivity_checker

パッケージ概要

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

デバイスの現在のインターネット接続状態に基づいて、動的なウィジェット管理を可能にするFlutterパッケージです。複数のプラットフォームでネットワークの利用可能性をリアルタイムでモニタリングし、開発者が条件付きでコンテンツを表示したり、ローディングインジケーターを表示したり、オフライン時にフォールバックUIをトリガーできるようにします。さまざまなネットワーク状態での応答性を求めるアプリにシームレスに統合できます。シンプルなAPIとクロスプラットフォーム対応により、接続状態に関係なく一貫したユーザー体験を保証します。

用途

  • オフラインバナーを表示しています
  • ネットワークに依存するウィジェットを条件付きでレンダリングする
  • オフライン時に再試行ボタンを表示する
  • 接続喪失時のロードプレースホルダー
  • ネットワーク認識機能を備えたAPIリクエストの処理
  • リアルタイムの接続状態の変化に基づいてUIを更新する

主な機能

  • リアルタイム接続モニタリング
  • クロスプラットフォーム互換性
  • ウィジェット制御のためのシンプルな API
  • 自動状態の更新
  • すべての主要なデスクトップおよびモバイルプラットフォームをサポートしています
  • 軽量で統合が簡単

適している対象

  • オフラインモード対応を必要とするアプリ
  • ネットワークに敏感なアプリケーション
  • 動的フィードバックを必要とするユーザーインターフェース
  • 応答性のあるネットワーク対応機能を構築する開発者
  • Android、iOS、macOS、Windows、Linux をターゲットにしたプロジェクト

注意事項

  • 一部のプラットフォームでは適切な権限が必要です
  • 例外的なケースに対する追加のエラー処理が必要になる可能性があります
  • 高頻度ポーリングのシナリオには適していません
  • 接続状態のみ(帯域幅は除く)
  • システムレベルのネットワーク検出APIに依存しています

元の README

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

internet_connectivity_checker

The connectivity package and other similar packages only provides information if there is a network connection, but not if the network is connected to the Internet. That's why the internet_connectivity_checker package helps you easily manage widgets dynamically based on the device's internet access.


Demo


🧑‍💻 Getting started

flutter pub add internet_connectivity_checker

🛠️ Usage

Simply import package:internet_connectivity_checker/internet_connectivity_checker.dart' and use the ConnectivityBuilder widget. It takes a builder and an optional parameter, interval(Duration object) which is the time interval to wait between each internet connectivity verification; default is 5 seconds.




Exemple
class Hello extends StatelessWidget {
  const Hello({super.key});

  @override
  Widget build(BuildContext context) {
    return ConnectivityBuilder(
      builder: (status) {
        bool connected = status == ConnectivityStatus.online;
        return Text(connected ? "Online" : "Offline");
      },
    );
  }
}

A more complete example.

ConnectivityBuilder(
  builder: (ConnectivityStatus status) {
    if (status == ConnectivityStatus.online) {
      return Container(
        decoration: BoxDecoration(
          color: Colors.green,
          borderRadius: BorderRadius.circular(15),
        ),
        child: Center(child: Text("Online", style: kTextStyle)),
      );
    } else if (status == ConnectivityStatus.offline) {
      return Container(
        decoration: BoxDecoration(
          color: Colors.red,
          borderRadius: BorderRadius.circular(15),
        ),
        child: Center(child: Text("Offline", style: kTextStyle)),
      );
    } else { // status == ConnectivityStatus.checking
      return const Center(
        child: SizedBox(
          width: 25,
          height: 25,
          child: CircularProgressIndicator(strokeWidth: 2),
        ),
      );
    }
  },
),

You can also use the ConnectivityChecker().stream stream, provided be the package, to handle the logic yourself.

class Foo extends StatelessWidget {
  const Foo({super.key});

  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
      stream: ConnectivityChecker(interval: const Duration(seconds: 10)).stream,
      builder: (context, snapshot) {
        if (snapshot.hasData && (snapshot.data as bool) == true) {
          return const Text("Online");
        } else if (snapshot.connectionState == ConnectionState.waiting) {
          return const Center(child: CircularProgressIndicator());
        } else {
          return const Text("Offline");
        }
      },
    );
  }
}

ℹ️ Additional Information

Contribute to this project by making a PR ⬆️ or creating a new issue 🐞 on GitHub.
Do not hesitate to let a 🌟 on the repo if you find it useful.

👷 Maintainers

Created & maintained with 💖 by moustapha.dev.

📄 License

MIT License

Copyright (c) Moustapha Ndoye (@csof3cen), 2023.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

カテゴリー

ソースリポジトリ

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

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