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

simple_connection_checker のカバー
パッケージ詳細v0.3.4

simple_connection_checker

デバイスがインターネットに接続されているかどうかを確認する簡単なパッケージ。また、接続状態の変更をリッスンするメソッドも提供しています。

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

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

flutter pub add simple_connection_checker

パッケージ概要

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

複数のプラットフォームでインターネット接続状態を簡単に検出できる軽量なFlutterパッケージです。デバイスがインターネットに接続されているかどうかを確認する簡単な方法を提供し、接続状態のリアルタイム変化をリッスンするストリームも提供しています。複雑なセットアップなしで信頼性の高いネットワーク状態監視が必要なアプリに最適です。Android、iOS、macOS、Windows、Linuxをサポートしており、クロスプラットフォーム開発に非常に柔軟に対応できます。

用途

  • API 呼び出しの前にインターネット接続を確認する
  • リアルタイムでネットワークステータスの変化をモニタリング
  • オフラインモードの処理を保証する
  • ネットワークステータスインジケーターを表示しています
  • 接続性に基づいてユーザー操作を検証する
  • ネットワーク状態が悪いときにリクエストの失敗を防ぐ

主な機能

  • 接続確認用のシンプルな API
  • ストリームベースの接続状態のリスニング
  • クロスプラットフォーム対応
  • 軽量で統合が簡単
  • 接続変更のリアルタイム更新
  • 追加の依存関係なし

適している対象

  • 基本的な接続モニタリング
  • ネットワーク認識を必要とするアプリ
  • 最小限のセットアップを求める開発者
  • クロスプラットフォームのモバイルおよびデスクトップアプリ
  • ネットワーク論理が限定されたプロジェクト
  • プロトタイプと迅速な実装

注意事項

  • Wi-Fi とセルラーの区別を処理しない
  • オンライン/オフライン状態のみに制限
  • 組み込みの再試行メカニズムなし
  • システムレベルの接続APIに依存しています
  • 一部のプラットフォームでは、権限の処理が必要になる場合があります
  • 高度なネットワーク診断には適していません

元の README

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

Simple Connection Checker

A simple package to check when the device is connected (connectivity) to internet. Also provide a method to listen for connection status changes.

Demo

Instalation

Include simple_connection_checker in your pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
  simple_connection_checker: version

Usage

To use this package, just import it into your file and call the static method isConnectedToInternet as follows:

import 'package:simple_connection_checker/simple_connection_checker.dart';

...

bool isConnected = await SimpleConnectionChecker.isConnectedToInternet();

...

Note: You can pass an optional parameter named lookUpAddress to pass an especific URL to make the lookup operation and check the internet connection. By default, this value is www.google.com. Do not use the protocol on the URL string passed (http:// or https://).

New 💥

  • A beta version to use with web
  • Now you can listen for internet connection changes. Here is the example
import 'package:simple_connection_checker/simple_connection_checker.dart';

...
StreamSubscription? subscription;
bool? _connected;

@override
void initState() {
  super.initState();
  SimpleConnectionChecker _simpleConnectionChecker = SimpleConnectionChecker()
      ..setLookUpAddress('pub.dev'); //Optional method to pass the lookup string
  subscription = _simpleConnectionChecker.onConnectionChange.listen((connected) {
    setState(() {
      _connected = connected;
    });
  });
}

@override
void dispose() {
  subscription?.cancel();
  super.dispose();
}

...

Note: Don't forget to cancel the subscription

Demo

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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

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