ConnectionNotifier는 인터넷 연결 상태를 모니터링하고 연결 상태가 변경될 때 실시간으로 업데이트를 제공하는 Flutter 패키지입니다. 인터넷에 접속할 수 없을 경우 사용자에게 즉시 알림을 보내기 때문에 신뢰할 수 있는 네트워크 인식이 필요한 앱에 이상적입니다. 이 패키지는 여러 플랫폼에서 연결 상태 확인 및 연결 이벤트 리스닝을 위한 간단한 API를 제공합니다. Android, iOS, Web, macOS, Windows, Linux를 지원하여 광범위한 호환성을 보장합니다. 사용이 쉬운 설계로, 복잡한 설정 없이도 개발자가 견고한 네트워크 처리 기능을 구현할 수 있도록 도와줍니다.
사용 사례
실시간 네트워크 상태 모니터링
앱에서 오프라인 시나리오 처리
네트워크 요청에 대한 자동 재시도 로직
연결 상태 UI 요소 표시
온라인 상태일 때만 데이터 동기화 보장
연결 변경 시 사용자 경험 개선
주요 기능
즉시 연결 변경 알림
연결성 확인을 위한 간단한 API
크로스 플랫폼 지원
경량이며 쉽게 통합 가능
이벤트 기반 아키텍처
내장 상태 추적
적합한 대상
신뢰할 수 있는 네트워크 감지가 필요한 앱
연결성 검사를 위한 최소 설정을 원하는 개발자
자주 네트워크 작업을 수행하는 프로젝트
명확한 연결 피드백이 필요한 사용자 중심 앱
크로스 플랫폼 일관성을 우선시하는 팀
고려 사항
모바일 플랫폼에서는 인터넷 권한이 필요합니다
예외적인 경우를 처리하기 위해 추가적인 오류 처리가 필요할 수 있습니다
고주파 폴링 시나리오에 적합하지 않습니다
기본적인 연결성 검사에 국한됨(세부 네트워크 메트릭 없음)
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Connection Notifier
A simple way to notify your user about the connection status as well as providing simple tools that help tracking the internet connection status.
Version 4.0+: Now with injectable connectivity handlers, full Navigator 2.0 support, Web support, and seamless support for modern routing solutions.
Version 4.1+: Added async connectivity check via ConnectionNotifierTools.isConnectedAsync.
Gallery
Quick Start
Basic Usage (Without Localization)
If you don't need localization, simply wrap your MaterialApp:
Recommended Approach: Use MaterialApp Builder (Best Practice)
The easiest and most powerful way to handle localization is using the MaterialApp builder pattern. This gives you full access to the localization context:
import'package:connection_notifier/connection_notifier.dart';
import'package:easy_localization/easy_localization.dart'; // or any localization packageimport'package:flutter/material.dart';
classMyAppextendsStatelessWidget{
@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
locale: context.locale,
supportedLocales: context.supportedLocales,
localizationsDelegates: context.localizationDelegates,
// Use the builder to access localization context
builder: (context, child) => GlobalConnectionNotifier(
connectionNotificationOptions: ConnectionNotificationOptions(
alignment: Alignment.bottomCenter,
// Access localized strings with full context support
connectedText: 'connectionRestored'.tr(context: context),
disconnectedText: 'connectionLost'.tr(context: context),
),
child: child!,
),
home: constMyHomePage(),
);
}
}
Benefits:
✅ Works with any localization package (EasyLocalization, flutter_localizations, intl, etc.)
✅ Messages automatically update when language changes
✅ Full access to localization context
✅ Clean and maintainable
✅ No need for custom widgets or manual locale detection
Alternative: Custom Notification Widgets
If you need more control over the UI, create custom widgets:
// Check if connected (synchronous, last known status)bool isConnected = ConnectionNotifierTools.isConnected;
// Async live check — use when you need a guaranteed up-to-date result,// since isConnected may briefly hold stale data during a connection change.bool isOnline = awaitConnectionNotifierTools.isConnectedAsync;
// Listen to connection changesConnectionNotifierTools.onStatusChange.listen((isConnected) {
print('Connection status: $isConnected');
});
Custom Connection Handler (Inject Your Own Connectivity Source)
The package is agnostic to how connectivity is detected. By default it uses
ConnectionNotifierHandlerImpl (internet_connection_checker_plus). If you have
your own source (socket, native SDK, etc.), implement ConnectionHandler and
pass it to ConnectionNotifierTools.initialize(...).
workspace-bridge-mcp — An MCP server that bridges AI coding agents with multi-project workspaces, enabling cross-project file access, git history, and more.