搜索插件、代码仓与 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

源码仓库

使用此插件的项目

暂无相关数据。