wifi_plus 0.0.2 copy "wifi_plus: ^0.0.2" to clipboard
wifi_plus: ^0.0.2 copied to clipboard

PlatformWindows

A robust and feature-rich Flutter plugin to scan, connect, disconnect, and manage Wi-Fi networks on Windows desktop applications.

wifi_manager #

A robust, premium, and feature-rich Flutter plugin to scan, connect, disconnect, and manage Wi-Fi networks on Windows desktop applications. It provides detailed network information, real-time connectivity status streams, and native WebView2-based captive portal authentication support.

Screenshots #

Available Networks Saved Profiles

Features #

  • 🔍 Wi-Fi Scanning: Scan for nearby Wi-Fi networks in range.
  • 🔌 Connection Management: Connect to open, secured (WPA/WPA2/WPA3), and Enterprise Wi-Fi networks, as well as disconnect or forget profiles.
  • 📊 Detailed Connection Info: Query the current active Wi-Fi connection, including SSID, IP address, MAC address, default gateway, DNS servers, link speeds (rx/tx), and signal strength.
  • 📈 Saved Profiles: Query the saved Wi-Fi network profiles stored on the system.
  • Real-time Event Streams:
    • onNetworksChanged: Triggers when nearby networks change.
    • onConnectionChanged: Triggers on connection status updates.
    • onSignalChanged: Emits signal strength percentages (0-100) dynamically.
    • onInternetChanged: Emits updates regarding internet availability, metered status, VPN status, and roaming.
    • onCaptivePortalDetected: Emits true when a captive portal (sign-in required) is detected on the network.
  • 🌐 Captive Portal Sign-in: Open and close native WebView2 authentication dialogs to sign into Wi-Fi captive portals directly from your app.
  • 🛡️ Robust Exception Handling: Custom typed exceptions for connection failure, wrong password, network not found, or permission issues.

Platform Support #

Platform Support Notes
Windows ✔ Supported Native C++ implementation (WlanApi & WebView2)
macOS ⏳ Planned Future support / Community contributions welcome
Linux ⏳ Planned Future support / Community contributions welcome
iOS ⏳ Planned Future support / Community contributions welcome
Android ⏳ Planned Future support / Community contributions welcome

Installation #

Add wifi_plus to your pubspec.yaml file:

dependencies:
  wifi_plus: ^0.0.1

Usage #

1. Scan for Nearby Networks #

Retrieve a list of nearby networks in range:

import 'package:wifi_plus/wifi_plus.dart';

try {
  List<WifiNetwork> networks = await WifiManager.scan();
  for (var network in networks) {
    print('SSID: ${network.ssid}, Strength: ${network.signalStrength}%, Security: ${network.security}');
  }
} on WifiException catch (e) {
  print('Failed to scan: ${e.message}');
}

2. Connect to a Network #

Connect to a Wi-Fi network. Supports open, WPA/WPA2/WPA3 (using password), and Enterprise (using username and password) networks:

try {
  // Connect to a WPA/WPA2 network
  await WifiManager.connect(
    ssid: 'Home-WiFi',
    password: 'my-super-secret-password',
  );
  print('Connected successfully!');
} on WrongPasswordException {
  print('Incorrect password!');
} on NetworkNotFoundException {
  print('Specified SSID is not in range.');
} on WifiException catch (e) {
  print('Failed to connect: ${e.message}');
}

3. Disconnect or Forget Networks #

Disconnect from the active Wi-Fi or delete a saved network profile from the system:

// Disconnect from the current network
await WifiManager.disconnect();

// Forget a saved network profile
await WifiManager.forget('Office-WiFi');

4. Fetch Connection Details #

Retrieve details of the active Wi-Fi connection:

WifiConnection? connection = await WifiManager.currentConnection();

if (connection != null) {
  print('Connected to: ${connection.ssid}');
  print('Local IP: ${connection.ipAddress}');
  print('Mac Address: ${connection.macAddress}');
  print('Signal Strength: ${connection.signalStrength}% (${connection.signalQuality})');
  print('Rx Speed: ${connection.rxSpeed} Mbps');
} else {
  print('Not connected to Wi-Fi');
}

5. Monitor Network Events (Streams) #

Listen to real-time changes on the network interface:

// 1. Monitor Signal Strength changes (0-100)
WifiManager.onSignalChanged.listen((strength) {
  print('Wi-Fi Signal Strength: $strength%');
});

// 2. Monitor active Connection changes
WifiManager.onConnectionChanged.listen((connection) {
  if (connection != null) {
    print('Connection updated: ${connection.ssid}');
  } else {
    print('Disconnected from Wi-Fi');
  }
});

// 3. Monitor internet availability / VPN status
WifiManager.onInternetChanged.listen((status) {
  print('Has Internet: ${status.internetAvailable}');
  print('VPN Active: ${status.isVpnActive}');
  print('Metered: ${status.isMetered}');
});

6. Captive Portal Sign-in #

Listen for captive portal detection, and launch a native WebView2 browser overlay so users can log in:

// Listen for captive portal requirements
WifiManager.onCaptivePortalDetected.listen((required) {
  if (required) {
    print('Captive portal detected! Directing user to sign in...');
    WifiManager.openCaptivePortal();
  }
});

Error Handling #

The plugin provides a hierarchical exception system for precision debugging:

  • WifiException: Base class for all plugin exceptions.
    • WifiPermissionDeniedException: Thrown if location or platform-specific privileges are missing.
    • WifiUnavailableException: Thrown if the Wi-Fi adapter is turned off or missing.
    • ConnectionFailedException: Thrown if the connection failed due to generic reasons.
    • WrongPasswordException: Thrown if the security key/passphrase is incorrect.
    • NetworkNotFoundException: Thrown if the SSID is not found or not in range.
    • UnsupportedSecurityException: Thrown if trying to connect using an unsupported protocol.
    • CaptivePortalException: Thrown if the captive portal fails to launch.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

0
likes
160
points
103
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A robust and feature-rich Flutter plugin to scan, connect, disconnect, and manage Wi-Fi networks on Windows desktop applications.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on wifi_plus

Packages that implement wifi_plus