패키지 :connectivity_plus
설치 : flutter pub add connectivity_plus
링크 : connectivity_plus | Flutter Package (pub.dev)
connectivity_plus | Flutter Package
Flutter plugin for discovering the state of the network (WiFi & mobile/cellular) connectivity on Android and iOS.
pub.dev
1. 단발(1회성) 확인
final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile) {
// I am connected to a mobile network.
} else if (connectivityResult == ConnectivityResult.wifi) {
// I am connected to a wifi network.
} else if (connectivityResult == ConnectivityResult.ethernet) {
// I am connected to a ethernet network.
} else if (connectivityResult == ConnectivityResult.vpn) {
// I am connected to a vpn network.
// Note for iOS and macOS:
// There is no separate network interface type for [vpn].
// It returns [other] on any device (also simulator)
} else if (connectivityResult == ConnectivityResult.bluetooth) {
// I am connected to a bluetooth.
} else if (connectivityResult == ConnectivityResult.other) {
// I am connected to a network which is not in the above mentioned networks.
} else if (connectivityResult == ConnectivityResult.none) {
// I am not connected to any network.
}
* 2가지 경우만 체크해도 될듯합니다.
'01.모바일 > Flutter' 카테고리의 다른 글
| [Flutter] Flutter앱에 Firebase 연동하기 (1) | 2024.03.11 |
|---|---|
| [Flutter] iOS 에러 - iPhone 15 Plus (0) | 2024.01.23 |
| [Flutter] GestureDetector 배경 없을때 클릭 영역 (0) | 2023.06.06 |
| [Flutter] DateTime weekday 요일 순서 (1) | 2022.09.21 |
| [Flutter] Release 배포용 키 만들기 (0) | 2022.08.01 |