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

套件詳情v2.0.1

wifi_configuration

Flutter Wifi 插件。

近 30 天下載
317
喜歡數
25
Pub 分數
150

安裝套件

flutter pub add wifi_configuration

套件介紹

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

一個 Flutter 插件,可在 Android 裝置上啟用 Wi-Fi 網路的設定與管理。它允許使用者以程式設計方式連接、斷開連接以及列出可用的 Wi-Fi 網路。此外,該插件專為需要直接與裝置 Wi-Fi 設定互動之應用程式所設計,例如網路設定工具或物聯網裝置設定器。它利用原生 Android API 提供穩定的連線控制。目前僅支援 Android,尚未有 iOS 版本。

適用情境

  • 為物聯網設備配置Wi-Fi
  • 自動化網路連接
  • 設定訪客網路
  • 管理自助服務終端的設備連接
  • 啟用自助式網路設定

主要特色

  • 連接到Wi-Fi網絡
  • 列出可用的Wi-Fi網路
  • 斷開與 Wi-Fi 的連接
  • 僅支援 Android
  • 網路管理的簡單 API

適合對象

  • 物聯網裝置設定應用程式
  • 自助服務應用程式
  • 網路自動化工具
  • 企業設備管理
  • 移動配置工具

使用建議

  • 僅限Android平台
  • 需要執行時權限
  • 可能需要使用者確認才能連接
  • 無 iOS 支援
  • 取決於設備製造商的實現

原始 README

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

wifi_configuration

Connect a Flutter app to a Wi-Fi network, read the current SSID, and list available networks on Android and iOS.

This is a Dart 3 rewrite of wifi_configuration 1.2.1. The Dart API is the same (connectToWifi, getWifiList, isConnectedToWifi, connectedToWifi).

Install

dependencies:
  wifi_configuration: ^2.0.0

Usage

import 'package:wifi_configuration/wifi_configuration.dart';

final WifiConnectionStatus status = await WifiConfiguration.connectToWifi(
  'OfficeNet',
  'passphrase',
);

switch (status) {
  case WifiConnectionStatus.connected:
  case WifiConnectionStatus.alreadyConnected:
    break;
  case WifiConnectionStatus.locationNotAllowed:
    // Ask the user to enable location / grant permission.
    break;
  default:
    break;
}

final List<String> nearby = await WifiConfiguration.getWifiList();
final String current = await WifiConfiguration.connectedToWifi();
final bool matches = await WifiConfiguration.isConnectedToWifi('OfficeNet');

packageName from 1.x is still accepted as an optional third argument and is ignored on current Android/iOS.

Platform notes

Android

Add nothing extra in most apps — the plugin manifest already requests:

  • ACCESS_FINE_LOCATION / ACCESS_COARSE_LOCATION
  • NEARBY_WIFI_DEVICES (Android 13+)
  • Wi-Fi and network state permissions

Location must be on. On Android 10+ the OS shows a system dialog to join the network (WifiNetworkSpecifier). That join is app-scoped and may not appear as a saved system network.

iOS

In Xcode, enable:

  1. Hotspot Configuration
  2. Access Wi-Fi Information
  3. Link NetworkExtension.framework

And in Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is used to read the current Wi-Fi name and join a network.</string>

Apple does not allow scanning nearby Wi-Fi. getWifiList() returns SSIDs this app has configured, not every hotspot in range.

Status values

Value Meaning
connected Joined the requested SSID
alreadyConnected Already on that SSID
notConnected Join failed or was cancelled
platformNotSupported OS version cannot configure Wi-Fi
profileAlreadyInstalled iOS already has a profile for this SSID
locationNotAllowed Location permission or services denied

Example

See the example/ app for a small UI that lists networks, shows the current SSID, and connects with a passphrase.

所屬分類

依賴

依賴清單 1 項

  • plugin_platform_interface^2.0.2

原始碼儲存庫

使用此套件的專案

暫無相關資料。