패키지, 저장소 및 앱 카테고리 검색

simple_connection_checker 표지
패키지 상세v0.3.4

simple_connection_checker

기기의 인터넷 연결 여부를 확인하는 간단한 패키지입니다. 또한 연결 상태 변경을 감시하는 메서드도 제공합니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
8.3천
좋아요
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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.