wifi_info_android 1.0.1 copy "wifi_info_android: ^1.0.1" to clipboard
wifi_info_android: ^1.0.1 copied to clipboard

PlatformAndroid

A plugin to get the wifi SSID, BSSID and RSSI on android

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:wifi_info_android/wifi_info_android.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Stream<WifiInfo?> checkConnectionStream() async* {
    var firstInfo = await WifiInfoAndroid.getWifiInfo();
    yield firstInfo;
    yield* Stream.periodic(const Duration(seconds: 2), (_) {
      return WifiInfoAndroid.getWifiInfo();
    }).asyncMap((event) => event);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('WiFi example app'),
        ),
        body: Center(
            child: StreamBuilder(
                stream: checkConnectionStream(),
                builder: (context, snapshot) {
                  final wifiInfo =
                      snapshot.connectionState == ConnectionState.waiting
                          ? null
                          : snapshot.data as WifiInfo?;

                  return wifiInfo == null
                      ? const Text('Could not get wifi info')
                      : Text(
                          'ssid: ${wifiInfo.ssid}, bssid: ${wifiInfo.bssid}, isConnected: ${wifiInfo.isConnected}, rssi: ${wifiInfo.rssi}\n');
                })),
      ),
    );
  }
}
1
likes
140
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

A plugin to get the wifi SSID, BSSID and RSSI on android

View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on wifi_info_android

Packages that implement wifi_info_android