wifi_hunter

A flutter package to hunt down info from all WiFi APs around you.

version BSD License PRs Welcome

Getting Started

The plugin only supports the android platform, and it's very unlikely to launch on iOS, because Apple refuses to provide permissions for that, so don't wait for that to come around. Credit where credit is due : This package is pretty much based on the wifi_info_plugin from @VTechJm, which you can check out here (https://github.com/VTechJm/wifi_info_plugin).

import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:wifi_hunter/wifi_hunter.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  WiFiInfoWrapper _wifiObject;

  @override
  void initState() {
    scanWiFi();
    super.initState();
  }

  Future<WiFiInfoWrapper> scanWiFi() async {
    WiFiInfoWrapper wifiObject;

    try {
      wifiObject = await WiFiHunter.huntRequest;
    } on PlatformException {}

    return wifiObject;
  }

  Future<void> scanHandler() async {
    _wifiObject = await scanWiFi();
    print("WiFi Results (SSIDs) : ");
    for (var i = 0; i < _wifiObject.ssids.length; i++) {
      print("- " + _wifiObject.ssids[i]);
    }
  }

  @override
  Widget build(BuildContext context) {
    scanHandler();

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('WiFiHunter Example App'),
        ),
        body: Center (
          child: Column (
            children: <Widget>[
              Text ("Scanning... Please check Log for results..."),
              FlatButton (
                child: Text ("ReScan (after prev. scan is finished; await...)"),
                onPressed: () => scanHandler(),
              )
            ],
          )
        )
      ),
    );
  }
}

Functionality and Features

Here is what infos you can get by using this package :

  • SSIDs ... _wifiObject.ssids

  • BSSIDs ... _wifiObject.bssids

  • Signal strength ... _wifiObject.signalStrengths

  • Frequencies ... _wifiObject.frequenies

  • Capabilities ... _wifiObject.capabilities

    ... of all WiFi APs in reach.

The available SSIDs, BSSIDs and capabilities (= protocols, ex. EES, WPA2...) are returned as Java List<String>, while the frequencies and signal strengths (dBm) are returned as List<Integer>.

If you want to run a scan again just execute scanHandler();, and your _wifiObject. results will be refreshed. Scans, for usual, can run every 3 seconds.

If anyone wants to, Pull requests are welcome 😉

Libraries

wifi_hunter

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]
dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.