搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.0

flutter_use_network_state

適用於 Flutter 應用程式的網路連線鈎子。提供 useNetworkState 鈎子來監控連線狀態、網路類型,並處理離線情境。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
58
喜歡數
1
Pub 分數
150

安裝套件

flutter pub add flutter_use_network_state

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,提供 useNetworkState 鉤子以監控應用程式中的網路連接。它讓開發者能夠追蹤即時連接狀態,偵測網路類型(例如 Wi-Fi、行動網路),並優雅地處理離線情境。適用於需要根據網路可用性實現回應式行為的應用程式,例如資料同步、載入狀態或連線變更時的使用者反饋。此套件支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。

適用情境

  • 即時網路狀態監控
  • 處理離線模式
  • 基於連接性的動態UI更新
  • 資料同步與網路檢查
  • 用戶在連接丟失期間的反饋

主要特色

  • useNetworkState 鉤子
  • 偵測網路類型
  • 支援多個平台
  • 離線場景處理
  • 即時連接狀態更新

適合對象

  • 需要網路感知的應用程式
  • 使用鈎子模式的開發人員
  • 跨平台網絡監控
  • 根據連接性自適應的UI
  • 離線優先的應用程式設計

使用建議

  • 移動設備上需要互聯網權限
  • 可能觸發頻繁重構
  • 平台特定的行為差異
  • 僅限基本連接檢測
  • 無內建重試邏輯

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

flutter_use

flutter_lints
Inspired by react-use.


A collection of Flutter Hooks inspired by React's react-use library. This monorepo contains multiple packages providing different categories of hooks for Flutter development.

📦 Packages

Package Description Version
flutter_use Core hooks library with essential utilities pub package
flutter_use_audio Audio playback and control hooks pub package
flutter_use_battery Battery state monitoring hooks pub package
flutter_use_geolocation Location and permission hooks pub package
flutter_use_network_state Network connectivity hooks pub package
flutter_use_sensors Device sensors hooks pub package
flutter_use_video Video playbook hooks pub package

🚀 Installation

For the core package:

flutter pub add flutter_use

For specialized packages:

flutter pub add flutter_use_audio    # Audio hooks
flutter pub add flutter_use_battery  # Battery hooks
# ... and so on

🌐 Interactive Demo Site

Try out all hooks with live examples at: https://wasabeef.github.io/flutter_use/

📚 Hooks by Category

📱 Mobile-first Hooks

Core package: flutter_use

  • useAsync — manages async operations with loading, data, and error states.
  • useDebounceFn — debounces function calls for better performance.
  • useInfiniteScroll — implements infinite scrolling with automatic loading.
  • useForm — comprehensive form state management with validation.
  • useKeyboard — tracks keyboard visibility and manages layouts (mobile only).
🎭 State Management

Core package: flutter_use

⏱️ Timing & Animation

Core package: flutter_use

🔄 Side Effects & Performance

Core package: flutter_use

🎯 UI Interactions

Core package: flutter_use

♻️ Lifecycle Management

Core package: flutter_use

🎨 Development & Debugging

Core package: flutter_use

  • useLogger — logs in console as component goes through life-cycles.
📱 Device Sensors

Package: flutter_use_sensors

Core package: flutter_use

🔋 Device Information

Package: flutter_use_battery

Package: flutter_use_geolocation

  • useGeolocation — tracks geo location and permission state of user's device. geolocator

Package: flutter_use_network_state

🎵 Media

Package: flutter_use_audio

  • useAudio — plays audio and exposes its controls. just_audio

Package: flutter_use_video

🚧 Coming Soon

  • useEvent — subscribe to events.
  • useFullscreen — display an element or video full-screen.
  • usePageLeave — triggers when mouse leaves page boundaries.
  • usePermission — query permission status for apps APIs.
  • useMethods — neat alternative to useReducer.
  • useSetState — creates setState method which works like this.setState.
  • usePromise — resolves promise only while component is mounted.
  • useObservable — tracks latest value of an Observable.



Unlicense — public domain.



所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。