wifi_connection 0.0.4 copy "wifi_connection: ^0.0.4" to clipboard
wifi_connection: ^0.0.4 copied to clipboard

Flutter plugin to get network statistics for iOS and Android

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:wifi_connection/WifiConnection.dart';
import 'package:wifi_connection/WifiInfo.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  WifiInfo _wifiInfo = WifiInfo();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    WifiInfo wifiInfo;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      wifiInfo = await WifiConnection.wifiInfo;
    } on PlatformException {
      wifiInfo = null;
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _wifiInfo = wifiInfo;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(children: [
            Text('SSID: ${_wifiInfo.ssid}\n'),
            Text('BSSID: ${_wifiInfo.bssid}\n'),
            Text('IP: ${_wifiInfo.ipAddress}\n'),
            Text('MAC Address: ${_wifiInfo.macAddress}\n'),
            Text('Link Speed: ${_wifiInfo.linkSpeed}\n'),
            Text('Signal Strength: ${_wifiInfo.signalStrength}\n'),
            Text('Frequency: ${_wifiInfo.frequency}\n'),
            Text('Channel: ${_wifiInfo.channel}\n'),
            Text('Network Id: ${_wifiInfo.networkId}\n'),
            Text('IsHiddenSSID: ${_wifiInfo.isHiddenSSID}\n'),
            Text('Router IP: ${_wifiInfo.routerIp}\n'),
            TextButton(
                onPressed: () {
                  initPlatformState();
                },
                child: Text('Refresh'))
          ]),
        ),
      ),
    );
  }
}
6
likes
130
pub points
44%
popularity

Publisher

unverified uploader

Flutter plugin to get network statistics for iOS and Android

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on wifi_connection